texts: Hacking the Imagecache module in order to serve images more easily

texts:
Possible Duplicate:
  No image upload is possible: Is there any workaround for this?

Since i have a busload of troubles with the image-upload in Drupal-Commons Version 6,25 i want to hack, tailer und tinker the imagecache-module.

Background: i have issues with the image upload: cf https://drupal.stackexchange.com/questions/25677/no-image-upload-is-possible-is-there-any-workaround-for-this

I have a fresh install of Drupal commons (version 6.25), and I am not allowed to upload an image.  What I am trying to do is to edit the super user profile, visiting example.com/?q=user/1/edit. What I get is the following error message:
Your virtual face or picture. Maximum dimensions are and the maximum size is kB. Minimum height is. The selected file paris_image.jpg could not be uploaded. Only JPEG, PNG and GIF images are allowed. What do I have to do? Do I need to change the permissions of some directories? Do I have to set up the commons more precicely, e.g. in the admin-area to allow any kind of images?

png
jpg
gif

Are there any workarounds for this? Note: this might have to do with Apache, the permissions and things like that. Update: I get a red message at the top of that page tells me the problem. I cannot fix it; I need to have access to the server to fix it.

Now i want to tailer and tinker the way that imagecache works: How to: First of all i recall all the features of the imagecache-module:

The Imagecache module is able to serve different versions of uploaded images.
It does this in an ingenious way, making it hard to diagnose once something goes wrong.  The following may show how Imagecache work?

Imagecache URL's In the Drupal menu system Imagecache can be found at the URL "//imagecache". Supposing you instructed Imagecache to create a "small" version of an image, the corresponding imagecache URL will look like this:

http://www.example.com/files/imagecache/small/files/pictures/img001.jpg

This is composed of four parts:

files - your Drupal files directory e.g. 'files' or 'sites/default/files'
imagecache - the module name
small - the imagecache version ("preset") name
pictures/img001.jpg - the path of the originally uploaded file

The trick Drupal's .htaccess file contains rewrite rules. Basically these rules say: Try to find whether a file matching the exact URL exists. If so, serve the file directly. If not, start Drupal and feed it the URL path.

If http://www.example.com/files/imagecache/small/files/pictures/img001.jpg is requested for the first time the file does not yet exist. So option 2 is chosen: Drupal is started and given the path /files/imagecache/small/files/pictures/img001.jpg. Drupal in turn starts imagecache and gives it the path /small/files/pictures/img001.jpg. This directs imagecache to create a "small" version of /files/pictures/img001.jpg.

At that moment imagecache does two things:

  It serves the small image back to the user. It copies the file to
  /files/imagecache/small/files/pictures/img001.jpg (if necessary
  creating subdirectories along the way).

and last but not least:

  You can guess what will happen the next time the file is requested:
  option 1 is chosen,the file is served directly. Now you know where the
  name imagecache comes from.

What is wanted: I want to hack the imagecache-module in order to get a quick and easy image-handling - without any issues.

Question: Well - what if i have weird issues with the imagcache all the times - what to do!?  I want to hack the module in order to get a fast and easy way of presenting the images! I want to tailor and tinker the imagecache-module. Can you assist me here.


texts:
I need some help adding text to the bottom of the registration form. I've never modified the registration form before and I did not set up this site.  Bootstrap Modal is being used for the form. Here is a screen capture of it:

The content needs a check box that must be checked for the submit button to work. Is there a module that can help, or, how do I locate this form to do some modifications?


texts: Getting 400 Error as A client error happened

texts:
On our multi-site platform using Drupal 8 hosted on acquia we are getting 400 error response on all the hosted websites

The error is not persistent but only occurs when user comes through a referrer like google/bing or even a link from JIRA/slack.

During this error, we see an error about 400 in Drupal Watchdog as

  drupal-watchdog.log-20181003:133708:Oct  2 13:46:06  d8: https://www.example-domain.com|1538487966|php||https://www.example-domain.com/|https://www.google.com/|0||Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "www.google.com". in Symfony\Component\HttpKernel\HttpKernel->handle() (line 71 of /mnt/www/html/d8/vendor/symfony/http-kernel/HttpKernel.php). request_id="v-8187594e-c649-11e8-b00d-67f570bebe6a"

As an attempt to fix the issue we tried adding 'www.google.com' in trusted_host_pattern in settings.php

  $settings['trusted_host_patterns'] = array(
    '^example-domain\.com$',
    '^.+\.example-domain\.com$',
    '^google\.com$',
    '^.+\.google\.com$',
  );

but that did not fix the issue either, we are still getting errors with that same logs.

We are using varnish for reverse proxy and cloudflare, if that looks to be an issue, since that's the thing between Drupal and client request.

Any help would be much appreciated.


texts:
I need to create an iframe to my payment provider that will do the actual payment in the checkout process of Drupal commerce.

In this iframe the user will actually insert his credit card details.

What is the best way to accomplish this?

I need this (of course) to interact with the commerce checkout process.


texts: How can I refer to a user in a content type using CCK in Drupal 7.7

texts:
In a content type I want to let the author select one or more of the site users. It's something like term reference field but I need to refer to a user instead. I can't find a suitable module for that although I can roughly remember that I did that before. I am using the latest drupal version 7.7.

Thanks


texts: Is there any technical reason why we now should put third-party modules in the [docroot]/modules folder? It seems like an odd inconsistency that common third-party modules go there, while multisite-specific modules go in the traditional /sites/[site]/modules folder. It appears that creating a sites/all/modules folder still works.


texts: How do I change jquery_update version for a custom theme?

texts:
There are two options in jquery_update module's configuration: Jquery to be used in frontend theme, and Jquery to be used in admin themes. I set another theme to be used by a specific role (say, manager).
How do I change jquery_update version of that theme that is used by manager role.
Is it possible to do this with template.php, if yes, how so?

I already followed a patch here, but I am not sure if I should apply that old patch.


texts: How to import multi-value fields into profile2 using the Migrate module

texts:
I have users each with a profile using the profile2 module. I am using a cookbook based on the Migrate framework to create the users and import profile data.

Sample CSV data would be:

"member_nr","email","username","tel_1"
"1001","new.tester@example.com","new tester","00000 12345-213"

But one of the profile fields is a text list using the checkboxes / radio buttons widget. According to the GUI, the values are stored in the format key|label.

So the field has values:

soccer|soccer
weight lifting|weight lifting
boxing|boxing
tennis|tennis
cooking|cooking

So I am trying to import data similar to:

"member_nr","email","username","tel_1", "interests"
"1001","new.tester@example.com","new tester","00000 12345-213", "soccer, weight lifting, boxing, tennis, cooking"

However, when running the import, I get an error that says:

  SQLSTATE[22001]:String data, right truncated: 1406 data too long for column field_interests' at row 1: INSERT INTO... [the data from the CSV file]

How should multi values be formatted in the CSV file to be accepted?


texts: Checking where are users coming from to the landing pages

texts:
We have a site that contains few "landing pages" of different campaings. Links to those landing pages are sent by newsletter. Now if user visit one of the landig pages I would like to programatically recognize if he is coming from outer source (from newsletter link) or is just browsing the site. Is it possible to recognize if the page is opened from email?

One of the solution could be to append a GET parameter to the newsletter links, but I'm afraid it will be not a good idea to force our customer to do it everytime. The other solution could be to check REFERER, but I'm not sure how reliable is this. If I could to decide that user is coming from outer source it could be enough.

What could be a suitable solution for this task?


texts: I run a panopoly project currently with many many addidtional modules. How to debug a closed-connection-error while uploading an image?


texts: I have the Content Access   7.x-1.2-beta1 module installed.  I would like to enable access to a few basic pages, not all of them, for everyone including unauthorized users.   I only see how to change the access for control for specific users or for all nodes of one type.  How would I fix this?  thanks!


texts: Theming paragraph fields from entity reference in view

texts:
I have a view (Drupal 8) where I load my entity reference field (display hidden), with three fields from a Paragraph type and a certain custom display).

The HTML markup looks like this now:

    Sogeti

020-55883366

    test@sogeti.nl

I can't find a way how to theme the fields. I don't get any template suggestions.


texts: Programmatically changing theme after hook_custom_theme

texts:
I'm trying to change the theme in code in drupal7.  hook_custom_theme is too early since I need spaces_init to have happened already.  The themekey module uses custom_theme so that's out.

The only method I've found so far is to change the theme callback using menu_alter.  What other options are there?


texts: hook_views_pre_execute() query not running (or being overwritten)

texts:
I'm trying to completely overwrite the query that's created by Views UI by using hook_views_pre_execute() in a custom module. I know about the new database API and how this function expects a SelectQuery object, but I've also read (in a posting from Lullabot, so I think it's legit) that if you're just writing a single query and don't need to do anything conditional, it's perfectly OK to skip that and just use db_query() with raw SQL.

So here's my function - the drupal_set_message() line is executing, but the output of the view is still sorted in ascending order, which is what is set in the Views UI. My understanding was that this function was supposed to completely overwrite what's in the UI, so how do I get it to work? (Right now I haven't done anything funky with the SQL except change the order by just to see if it would work. There really is other stuff that needs to be done which justifies using a module instead of the Views UI.)

function group_speaker_carousel_views_pre_execute(&$view){
    if ($view->name == 'speakers_carousel')  {
      drupal_set_message("view is {$view->name}");
       db_query("SELECT DISTINCT node.title AS node_title, node.nid AS nid, field_speaker_node.title AS field_speaker_node_title, field_speaker_node.nid AS field_speaker_node_nid,  'node' AS field_data_field_job_title_node_entity_type,  'node' AS field_data_field_company_node_entity_type
      }
FROM {node} node
LEFT JOIN {field_data_field_speaker} field_data_field_speaker ON node.nid = field_data_field_speaker.field_speaker_target_id
LEFT JOIN {node} field_speaker_node ON field_data_field_speaker.entity_id = field_speaker_node.nid
WHERE (((node.status =  '1') AND (node.type IN ('speaker'))))
ORDER BY field_speaker_node_title DESC");

    }
}


texts: How can I put a time-delayed lock on a node?

texts:
I'm using Drupal 7, and would like to add a time-delayed lock to a specific node type: when a node of that type is created, the creator of the node has fifteen minutes to edit that node. The node then locks and its state changes in workflow.module.

What's the best way to achieve this result?


texts: How can I get translation for a field of custom date

texts:
I am using the paragraphs module. I have a field which contains a date and time e.g. for events, which is added by an author. For the output I use a paragraph-twig-file and I have this:

<div class="timeline-date">
    {{ content.field_date }}
</div>

In the backend of Drupal I created a custom time "D, d.m.Y - H:i". The output is right e.g. "Fri, 24.08.2018 - 17:14", but my site is in german and not english. So how, can I translate the day of week in german?
In my case this solution is not working


texts: Sorting logic with anonymous function does not work

texts:
This question is related to my previous question about how to change the sort order in a view. Since this is a new question I thought I better post a new one.

My new problem is that I use hook_views_pre_render() as suggested, but I am having trouble getting the views sort order right. I use an anonymous function like this to change the views order:

/**
* Implementation of hook_views_pre_render. Sorts the nodes under "Givare"
 */
function mysite_views_pre_render(&$view) {
    if ($view->name === 'related_items' && $view->current_display === 'probes') {
        $node = node_load(arg(1));
        $sortorder = array();
        $groups = $node->field_lagg_till_givargrupp['und'];
        foreach($groups as $group){
            $group_nid = $group['nid'];
            $group_node = node_load($group_nid);
            $probe_nids = $group_node->field_koppla_givare['und'];
            foreach($probe_nids as $probe_nid){
                $sortorder[] = $probe_nid['nid'];
            }
        }

        usort($view->result, function ($a, $b) use ($sortorder) {
            $cmpa = array_search($a->nid, $sortorder);
            $cmpb = array_search($b->nid, $sortorder);
            dsm($a->nid." ".$b->nid." ".$cmpa." ".$cmpb);
            if($cmpa === $cmpb) {
                return 0;
            }
            return ($cmpa < $cmpb) ? -1 : 1;
        });
    }
}

The variable $sortorder contains an array with nids in the wanted order. But the resulting $views_result does not follow that order (but it is altered, just in the wrong way). Can anyone see what I am doing wrong?

EDITED: added context – the view in question is a block display with a grid setting (there are several of these block displays in the same view and these block displays are used by Quick Tabs to render each block under a tab as related items.) In this particular block display I have tested to omit exposed filters, to deselect grouping by title etcetera to see if that would impact the sorting, but with no luck. I was surprised that this block needed sorting at all because I give the order explicitely with a contextual filter. See this question for the contextual filter:
Sort criteria is ignored in Views

Also, as I added the row dsm($a->nid." ".$b->nid." ".$cmpa." ".$cmpb); I can see that there are more than one hundred value pairs, but there are only 22 items to be rendered(!). The first few rows of that dsm() looks like this, where for example the nid 20726 is repeated several times:

  20726 20693 7 12

  21863 20726 5 7

  20726 20695 7 4

  20726 20697 7 0

  20726 20699 7 15

  20861 20726 21 7

  20860 20726 20 7

  20859 20726 19 7

  20858 20726 23 7

  20857 20726 22 7

  20768 20726 2 7


texts: Add title and alternate text to image automatically?

texts:
In my site users can upload content and also images.

My goal is that when a user is uploading content to the site, and also an image - the title of the content will be also the image title and the alternate text of the image.
Currently I am using the core image field.

Is there a way or a module that can achieve all that?


texts:
I've a question.

I'm running a site where I'm using OG' and apache solr. I cant seem to figure out a way for the search to just search through maybe 2+ or more then 1 group.

Any help would be appreciated.


texts: Is there a way to upload files to the theme directory

texts:
I use the following code to upload images should be used in slideshow of the theme settings theme-settings.php:

for ($i = 0; $i < 7; $i++){
      $form['best_responsive_settings']['slideshow']['slideimages'][] = array(
        '#type' => 'managed_file',
        '#title' => t('Image').' #'.$i,
        '#upload_location' => file_default_scheme() . '://theme/backgrounds/',
    '#default_value' => theme_get_setting('background_file'),
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg')),

      );
  }

Those files are uploaded to: sites\default\files\theme\backgrounds I want to change the uploading location to sites\all\themes\best_responsive\images\backgrounds. How could I change '#upload_location' to do that?


texts: manually adding terms to nodes directly from db

texts:
I have lots of nodes in my system. I want to add them some taxonomy terms.

I have a CSV file for each term, and in this file I have the list of node id's. Example:

apples.csv:

5
9
12
24
....
....

SO I need node 5, 9, 12 and 24 to have the term "apples".

I wrote a php script to directly add that term to each of the nodes. That script populates the table "field_data_field_category" correctly.

I can also see the term on the node page.

The problem is the nodes dont appear in the term page. Also if I create a view to display nodes of specific term, it becomes empty.

Is there another table to keep the node - term relationship?

EDIT:

I just found that there is another table keeping the relationship between node and term: taxonomy_index: "Maintains denormalized information about node/term..."

How does this table populated? On a cron run? Because I see some of my node - term pairs there. Some not.


texts:
i created a field called : (sitename_ar) and i have two rows (two domains) in  {domain} field :

and i have in my database these two fields {node} and {domain_access} :

and i want display in view page:
node : Title
node : Domain (sitename_ar)
i have created a view and i added a Title field and a Global:php field to call rows from database :

and i addedd those lines :

but always it display the same field (the first row) :

How i can Join all those 3 fields and display for each node her domain (with sitename_ar)


texts: How do I get a freshly updated value (i.e. not the cached value) using entity_metadata_wrapper?

texts:
In my code I am inserting a new value into the database directly using db_insert (i.e. inserting an entirely new row).  The type of field, however, already exists in Drupal which is called "field_data_field_email_address".  Previous to the insert call no value existed in the database which is associated with an entity.

Later in code I am relying on entity_metadata_wrapper to retrieve the values associated with the entity.  The problem is that the wrapper doesn't retrieve the most recently inserted value but instead returns nothing.  Yet when I look in the database table I can clearly see the existence of the newly inserted value.

As you may have already guessed I narrowed the issue down to a caching issue because if I clear the Drupal cache the wrapper returns the newly created value just fine.

My question is this: How can I force the entity_metadata_wrapper call to not retrieve the cached version but refresh and return to me the actual current values that exist in the database.  I need my wrapper to represent the freshest data and not the cached version.

Thank you in advance!


texts: Why are the terms filled when they are actually empty?

texts:
Below is the JSON output of a product I am having the issue with:

  {
     "StkGrupKodu1" : "10090",
     "StokAdi" : "7 Parça Kombine Anahtar Takımı",
     "StkGrupKodu2" : "",
     "SiparisVerilebilir" : true,
     "StokMiktari" : 0,
     "StkGrupKodu4" : "",
     "StokTipiAdi" : "Ticari Mallar",
     "KDVOrani" : 18,
     "StokTipi" : "00000",
     "DovizCinsi" : "EUR",
     "Fiyat" : "34.00000",
     "StkGrupKodu3" : "",
     "StkGrupKodu5" : "",
     "PasifStok" : false,
     "EskiBilgileri" : {
        "EskiStokKodu" : "",
        "DegistirmeTarihi" : "1920-04-23T00:00:00"
     },
     "StokKodu" : "JBM50563"
  },

In this e-commerce system, I am consuming a web service and creating corresponding products. With a few products such as the above and a few others, I am having this dreadful issue. As you can see, StkGrupKodu2 and StkGrupKodu3 are empty but when I go to the edit page of the product, it's not empty. You can see from the screenshot below:

This is the code I am using to associate terms with products

foreach ($excel_products as $e) {
    $req = \Drupal::httpClient()->get("http://mitapp.mitacan.com/b2b/api/vStkLib/GetStkKodlist?UserCode=B2BUSER&StokKodu=".$e->stokkodu);
    $res = $req->getBody();
    $res = json_decode($res);
    $data = $res->Data[0];
    $sid = \Drupal::database()->select("commerce_store_field_data", "csfd")->fields("csfd", ["store_id"])->condition("default_currency", ($data->DovizCinsi == "TRL")?"TRY":$data->DovizCinsi)->execute()->fetchCol();
    $product = Product::create(["type" => "default"]);
    <snip>
    if (!empty($data->StkGrupKodu1)) {
        $tid_1 = \Drupal::database()->select("taxonomy_term__field_stok_grup_kodu", "ttfsgk")->fields("ttfsgk", ["entity_id"])->condition("field_stok_grup_kodu_value", $data->StkGrupKodu1)->execute()->fetchCol();
        $tid_1 = (!empty($tid_1[0]))?$tid_1[0]:"";
    }
    if (!empty($data->StkGrupKodu2)) {
        $tid_2 = \Drupal::database()->select("taxonomy_term__field_stok_grup_kodu", "ttfsgk")->fields("ttfsgk", ["entity_id"])->condition("field_stok_grup_kodu_value", $data->StkGrupKodu2)->execute()->fetchCol();
        $tid_2 = (!empty($tid_2[0]))?$tid_2[0]:"";
    }
    if (!empty($data->StkGrupKodu3)) {
        $tid_3 = \Drupal::database()->select("taxonomy_term__field_stok_grup_kodu", "ttfsgk")->fields("ttfsgk", ["entity_id"])->condition("field_stok_grup_kodu_value", $data->StkGrupKodu3)->execute()->fetchCol();
        $tid_3 = (!empty($tid_3[0]))?$tid_3[0]:"";
    }
    $tids = [$tid_1, $tid_2, $tid_3];
    $tids = array_filter($tids);
    <snip>
    foreach ($tids as $tid) {
        $product->field_stok_grup_adi[] = [
            "target_id" => $tid,
        ];
    }
  <snip>
}

What am I doing wrong or missing?


texts: How do I highlight an element in a view result?

texts:
I have a "Collection" content type, and a "Product" content type.

Each "Product" node has a node reference to a "Collection" node, and a "Collection" node can have several "Product" nodes referring it, while a "Product" node can only belong to one "Collection" node.

I created a view to list all collection as photo thumbs with link to collection node. I display this list as a footer in collection nodes and products nodes.

What I want to do as "special" is to highlight current collection in the collections footer when I display a product node which belongs to this collection. Same thing when I display the collection itself.

Is it possible to do this using views and as possible without Javascript?


texts: "$.fieldValue is not a function" alert on login form submit

texts:
In Drupal 7, with Devel, CTools and Ajax Login/Register plugins, I get an alert on submitting the login form on http://p262957.mittwaldserver.info/drupal/user/login.

I am using a custom child theme based on bootstrap project. I already tried the instructions on https://www.drupal.org/node/1008664 that says I should be sure to load jquery.form.js before ajax.js.

Does anybody have an idea?


texts: How to hide empty ratings using Rate module?

texts: I run a site that uses the Rate module on Drupal 7, using the 5 star rating.  A lot of the items haven't got any ratings yet, so are displayed as 5 blank stars, which makes it look like they've got a score of 0 out of 5.  Is there a way of only displaying a score if there is at least one rating?


texts: Adding additional option under node publish options

texts:
In add /edit node page under publish options there are four option available

Published
Promoted to front page
Sticky at top of lists
Create new revision

Is there a possibility to add a 5th one for example Active and can use that option in views so that only the nodes which are they appear other nodes must not.

I am a themer not a coder so, I would really appreciate if your answer can also contain the code or reference or descriptive how to steps.

Thanks in advance


texts: How to add Specific Class to Each Drupal Menu Anchor

texts:
I am developing a website using drupal and i need to know about how to add link to drupal menu anchor.

For example:

i have a drupal menu: user menu. Within user menu, i have several list of links, let's say: A, B, C, D.

Then, i want to add class/id for each of the anchor, such as: A

Thank you.


texts: How to create drop down while the menu structure is in array type?

texts:
I have created menus with sub-menus in the header.

It is supported by some themes .

But some themes don't support this. e.g Bartik, fontfolio etc.

I want to use the drop down as customized in the main-menu region, so as to display in these themes also.

How can I edit this in the drupal page.tpl?

As I am new to drupal, please suggest me.

E.g Dropdown not Supported in this format:

    <?php print theme('links__system_main_menu', array(
      'links' => $main_menu,
      'attributes' => array(
        'id' => 'menu',
        'class' => array('links', 'inline', 'clearfix', 'menu'),
      ),
      'heading' => array(
        'text' => t('Menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      )));
    ?>


texts: How to redirect custom ajax form to external url

texts:
When setting the form with ajax handler like this

  public function buildForm(array $form, FormStateInterface $form_state) {
    //...

    $form['actions']['submit'] = array(
      //...
      '#ajax' => [
        'wrapper' => 'custom_form_wrapper',
        'callback' => '::ajaxCallback',
      ],
    );
  }

and trying to set the redirect on submitForm

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $url = 'https://example.com';
    $form_state->setResponse(new \Drupal\Core\Routing\TrustedRedirectResponse($url, 302));
  }

nothing happens and no error message appears but the form seems like it has finished processing.

When the ajax part is taken out the action:submit array the form redirects properly on submit.  What should be done differently ?


texts: SearchAPI Autocomplete - Pass in contextual filter to alter query

texts:
I'm trying to modify the Autocomplete module query with hook_search_api_alter_query. I would like to pass in the contextual filter of the page I embed the search in into the module so I can add it to the query. In a hook_search_api_alter_query function I wrote, I just used arg(1), which works for the actual search, however when the autocomplete module runs, var_dump(arg(1)) returns Response Type: string(33) followed by the autocomplete results and their html tags.

Is it possible to pass in the contextual filter into the autocomplete module so that I can use it , since the contextual filter has been changed to /search_api_autocomplete/search_api_views_[view name]/-?

My current query alter hook:

    function hook_search_api_query_alter(SearchApiQueryInterface $query) {
      var_dump(arg(1));
        $prod_code = arg(1);
        $tid = taxonomy_get_term_by_name($prod_code);
        if (!empty($tid)) {
            $base_filter = $query->createFilter('AND');
            $or_filter = $query->createFilter('OR');
            while (!empty($tid)) {
                $or_filter->condition('field_prod_code', array_shift($tid)->tid);
            }
            $base_filter->filter($or_filter);
            $query->filter($base_filter);
        }
    }

My problem is that arg(1) within the autocomplete module isn't the taxonomy term, therefore the function doesn't go through the if statement. I need a way to get the contextual filter for the autocomplete function so that it can alter my query like it does when searching.


texts: Display only last item in multifileld (files by media)

texts:
I added one multifield - files with media widget.
Drupal rendered all items, but I need only last.
I can fix this by code below in template.php, but i don't know, it is good?

$i = 0;
while($i < $items_count - 1) {
  unset($variables['content']['field_files'][$i]);
  unset($variables['content']['field_files']['$items'][$i]);
  $i++;
}

What is the best way?


texts: How to check that cache is working on current page?

texts: Some modules silently turn off caching on certain pages. How is the easiest way to check that this is the case and also identify problematic module?


texts: Can't locate where Commerce Authnet stores the API and Key

texts:
I am using Drupal Commerce and the Commerce_authnet module to connected to Authorize.net. I have custom functionality which requires me to make a separate call to the Authorize.net CIM API. I have done so sucessfully by adding a submit handler to the Checkout button, catching the API Login and Key, and used those in my API calls.

$login = $form_state['values']['commerce_payment']['payment_methods']['authnet_aim|rules_authorize_net_aim_credit_card_test_association']['settings']['login'];
$key = $form_state['values']['commerce_payment']['payment_methods']['authnet_aim|rules_authorize_net_aim_credit_card_test_association']['settings']['tran_key'];
define("AUTHORIZENET_API_LOGIN_ID", $login);
define("AUTHORIZENET_TRANSACTION_KEY", $key);

However, I need to create a separate way of users updating their Authorize.net account settings from their user profile form. I have looked in the commerce database tables and in the drupal variable editor to see if I could pull it from the database, but I have not found where its stored.
How can I access this data?


texts:
Most of console commands are missing from the output of drupal list.

I am using Drupal Console version 0.11.3, which outputs the following error message.

  [WARNING] In order to list all of the available commands you should install Drupal first.

The multi-site is correctly configured.

I have created an empty /sites/default/settings.php and it is still not working, i.e. it still not showing most of the Drupal console commands.

Why do I get that error message?


texts: Why is the drush views-list command complaining (incorrectly) that views is not enabled?

texts:
I am running drush version 5.3:

rob@drupaldev:/var/www/drupal$ sudo drush version
drush version 5.3

When I attempt to execute the views-list command it says that the views module is note enabled.

rob@drupaldev:/var/www/drupal$ sudo drush views-list
Command views-list needs the following module(s) enabled to run:     [error]
views.
The drush command 'views-list' could not be executed.                [error]

However, the module is already enabled:

rob@drupaldev:/var/www/drupal$ sudo drush pm-list|grep -i views
 Chaos tool   Views content panes              Module  Not installed  7.x-1.0
 suite        (views_content)
 Views        Views (views)                    Module  Enabled        7.x-3.3
 Views        Views UI (views_ui)              Module  Enabled        7.x-3.3

Any ideas what else could be causing this?

Greg suggested that it could be a permissions issue or an environment issue caused by the necessity of using sudo. After having fixed one of my permission issues, I can reliably run drush with or without sudo. In either case it returns true.

rob@drupaldev:/var/www/drupal$ sudo drush ev 'var_export(module_exists("views"));'
truerob@drupaldev:/var/www/drupal$ drush ev 'var_export(module_exists("views"));'
truerob@drupaldev:/var/www/drupal$


texts: How to change the field label on my registration form? Drupal 7

texts:
On the default registration form, I want to change the Username label to 'Request your username'

I tried putting this in my template.php::

function mymodule_form_alter(&$form, &$form_state, $form_id)
{
    if ($form_id == 'user_register_form' || $form_id == 'user_profile_form') {
        $form['account']['name']['#title'] = t('Request your username');
    }
}

I cleared cache, but didn't see any changes.


texts:
Pathauto was working for me in the past but just now, after setting a new pattern for my content clicking bulk update while checking every single content type to be sure, I get the "No new URL aliases to generate" message.

I even tried changing the pattern of my other content that already has generated url aliases and ran bulk update later, but I still got the "No new URL aliases to generate" message.

How can I debug this problem? My pattern is straightforward:

blogs/[node:title]

Devel shows that the [node:title] token exists.


texts: Printing block on all pages of a contenttype

texts:
In my page--front.tpl.php i have a menu block rendered using:

<?php
$block = block_load('menu', 'menu-basic-menu');
print render(_block_get_renderable_array(_block_render_blocks(array($block))));
?>

Which works as expected.

What should i do to print this block on all pages of a specific content type?

Help appreciated


texts:
how to add cache tag in custom RSS feed in Drupal 8
I have tried like this

    use Symfony\Component\HttpFoundation\Response;
    $response = new Response();
    $xml_content = '<?xml version="1.0" encoding="UTF-8"?>
     <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
      <channel>
       <title><![CDATA[ Title there ]]></title>
       <link><![CDATA[ siteurl.com ]]></link>
       <description><![CDATA[ description there ]]></description>
      </channel>
     </rss>';
    $cacheTags = ['node:nid', 'node:nid']
    $response->setContent($xml_content);
    $response->setCache(['etag' => $cacheTags]);
    $response->headers->set('Content-Type', 'xml');

but it not working


texts: How do I override ajax-progress-throbber in a theme?

texts:
In my Drupal 7 site, I created a custom theme. In my theme, I want to change the AJAX progress throbber HTML structure, which by default is the following one.

&nbsp;

Please wait...

I searched a lot about this issue, but I couldn't find any useful document or sample.


texts: How to print You have new private message, You have no new messages

texts: I'm using Privatemsg module and I want to print simple "You have new message" and "You have no new messages" for given user how to do that?


texts: How can I submit a list of flagged nodes to the admin user?

texts:
I'm using the Flag module to make a list of items that a user would like more information on. The user flags each node and those are added to a flag list. I would like to allow the user to submit this list to the admin user somehow but have not yet found a way of doing so. I'm using Drupal 7.

Thanks kindly in advance!


texts:
I am looking for some kind of Ajax-based slideshow/banner module for D7 for a changeable front-page photo banner. Unfortunately neither Views Slideshow Ajax nor Ajax Slideshow have been ported to D7 yet. I have several megabytes of photo content and would like to load each image on demand, not load them all at once (which is, as I understand, how most of the slideshow modules work). Right now I am just using a view that returns a randomly-chosen image, but I'd rather have it cyclable by the user with arrows or by a timer.

Are there any existing D7 modules that do something like this? There are so many slideshow, banner, and gallery modules: I may have missed the one I need.


texts:
Hello i am trying to override a node view without much success. I dont know if its just the syntax for my view thats wrong.

When i go to theme information the Row Style output tpl suggestion is

views-view-row-node--taxonomy-term--page-3.tpl.php

i can override that fine but it suggests it would be better to overide node-view-VIEWNAME.tpl.php

So i have a tpl file named

node-view-taxonomy-term-page-3.tpl.php

but it doesnt seem to want to override. Am i missing maybe a '-' somewhere in the tpl title?

I am using Views 3 and D6. I have the tpl in the same folder as my node.tpl.php

all help appreciated thanks.


texts: How to make Simple hierarchical select always displays 2 lists?

texts:
I'm using drupal 7 with the simple hierarchical module.

In my case, I always have 2 levels taxonomies (parent - 1 or more child (s)). Now the shs module works well, it shows always a first dropdown list, when I choose one term, a second dropdown fade in and displays multiple child. (I've checked the option force users to always select a child on the shs parameters).

My problem, imagine some day I'll have a term (parent) without any child. shs would probably display this parent in the first list, imagine I choose this term (for the shs I can't go deeper because no childs for this term) The probleme is : my project MUST have children terms.

I can't force users to create children when creating taxonomies (a user can create a parent today and save it, and someday he'll create child terms for this term), I want to make shs displays ALWAYS the first dropdown list (parents) and ALWAYS a second dropdown (children) even if it just displays "none" and will contain the real child when a parent would be selected. And when user choose the parent that do not have cheldren (none will stay on second dropdown) At this moment, my shs is configured to display the error message "go deeper" he probably want to go "deeper" and surprise: no child, there is only 'none' and at this moment, he will go to create child..

For example :

imagine the term "A" in the attached file, has no child terms, and even if it's that case, we would have a second dropdown with "none".
thank you


texts: Remove Administration Theme from user/%/edit

texts:
I want the administration theme for all the default pages, except one: /user/%/edit

How do I get the default theme to display for this page instead of the administration theme?


texts: How to pass theme variables in #theme in a form element?

texts:
I need to pass product variable defined in hook_theme() and invoked in #theme
but not sure how to pass product variables in #theme
Please suggest.

    function storeinv_theme() {
      return array(
        'storeinv_pickup' => array(
          'variables' => array('product' => NULL),
        ),
      );
    }

    function storeinv_uc_product_description($product)      {
      $description = array(
        'pickup' => array(
          '#product' => array(
             '#type' => 'value',
             '#value' => $product,
           ),
           '#theme'  =>'storeinv_pickup',
           '#weight' => 1,
         ),
      );

       return $description;
}

    function theme_storeinv_pickup($product){

            $data = $product['#value']->data;

            if (isset($data['pickup']['store_id']))
            {
                    $store_id = $data['pickup']['store_id'];
                    $day = $data['pickup']['day'];
                    $date = date( 'l m/d/Y g:ia', strtotime( $day ) );
                    $result = views_get_view_result('field_altstoreid_value','default');
                    foreach($result as $k => $v){
                      if ($store_id == $v->field_altstoreid){
                            $name = $v->title;
                            return "<p>Pickup " .$date."at " . $name." </p>";
                      }
                    }
            }
            else {
                    return '';
            }
    }


texts: drupal moving from local host to live server - error

texts:
Error
The website encountered an unexpected error. Please try again later.
Error message

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' in lock_may_be_available() (line 167 of /httpdocs/includes/lock.inc).

I am getting the above error after deploying a website on server.

Basically, I created a Drupal website on local server. After finishing it, I generate the database script and run it on live server using phpmyadmin. and then I upload and files on server and change the setting file for database connectivity.

Once I tried to access the website, I am getting the above error like I said before.

I find this solution. but because I am running a dedicated server and don't want to update phpmyadmin. So, I am looking for way around.

clue


texts: Workbench access - how to limit which which menus user can add to

texts:
I have a workbench workflow system that's setup using a taxonomy to manage the sections. Is it possible to restrict which menu items a node can be added to, depending on a user's section.

Even without Workbench access, any suggestions of limiting how to restrict which menus/menu items users can add to would be appreciated.


texts: How to remove span from rewrite result in a field view?

texts:
In a custom view I have several fields excluded from display.
I wanted to use their values within an global:fieldset with rewrite output option.
This works but the values are embedded in a  that I don't want, and I didn't find the way to remove it. i.e. if rewrite text use the replacement patterns [field1],[field2],[field3] I got as result

field1 result, field2 result, field3 result

instead of only:
field1 result, field2 result, field3 result


texts: Ajax Callback to Update Select List not Working

texts:
I have defined couple of fields inside my custom entity basefielddefinitions() like so...
$fields['product_line'] = BaseFieldDefinition::create('entity_reference')...
$fields['product'] = BaseFieldDefinition::create('entity_reference')....
Then in entity form class (ProductLineForm.php), I try to attach an ajax callback to my product_line select list such that it populates the product select list, like this
    $form['product_line']['#group'] = 'details';
    $form['product_line']['#ajax'] = [
      'callback' => '::populateProducts',
      'event' => 'change',
      'wrapper' => 'edit-products'
    ];

Then my product select list looks like this...
    $form['product']['#group'] = 'details';
    $form['product']['#attributes'] = [
      'id' => 'edit-products',
    ];

and then my populateProducts() function...
  public function populateProducts(array $form, FormStateInterface $form_state) {
    $form['product']['#options'] = ['1' => 'One', '2' => 'Two'];
    $form_state->setRebuild(TRUE);
    $response = new AjaxResponse();
    $option = "<option value='45'>Just testing</option>";
    $response->addCommand(
      new \Drupal\Core\Ajax\ReplaceCommand(
        '#edit-products',
        ($form['product'])
      )
    );

    return $response;
  }

The problem is that nothing whatsoever happens, no signs of any ajax call, and the product select list stays empty as it always been.
(1)Is the the entityform class the right place for me to attach an #ajax call to a field defined in a custom entity? Or do I need a hook? Meanwhile I've done a lot of other modifications on the custom fields here in this entity form edit class (like grouping into fieldsets, vertical tabs and even modifying weight (eg $form['product_line']['#weight'] = 3 - and they all work, why not $form['product_line']['#ajax']....?
(2) Is there a way of attaching the ajax callback directly inside my custom entity's basefielddefinitions where I define the fields, I would prefer that...
Really stuck on this one, folks, please could someone help me? Appreciate all your input, Thank you all.


texts:
Drupal core module Aggregator produces feed titles like:

One two three four five six seven, all good children go to heaven.

I want this displayed:

One two three four five six seven, all good children

How to get this done?

Someone hinted that the Smart Trim module offers this option but I can't get it working in combination with Aggregator and Panels. How to do this?


texts: How to show the distance relative to the user's location?

texts:
I'm trying to recreate a site, and one part of the content is supposed to show the distance relative to the user's location, like this:

Does anyone know of a way I can accomplish this?


texts: Programatically Attach a Field to a CCK Type in Drupal 6

texts:
I am in the situation where I need to made some modifications to a content type in my .install file. I know how to create a content type programatically, just create it via the UI and export, and recreate the form to submit it.

But in this case deleting the existing content type and recreating it screws up the existing content type instances, so I need to add an existing field to an existing content type. Is that easy to do programatically?

Also what's up with Drupal's API or lack thereof to do these kinds of things? I'd love to do something like:

$foo_content_type = get_content_type('foo');
$foo_content_type->add_field( $the_field );

Why is this kind of stuff so bound to the UI? Is it just because of the historical development of Drupal? I'd say design the programatic API first, then bind the UI to that...
Is Drupal 7 much better?


texts: How can I "catch" first visit of specific user today?

texts:
I have to know when specific user start to visit site every day.
I need server solution (cookie files are unsuitable).
What hook can be useful?

UPDATE
Possible solution:
Create date field for user. Fill with cron at midnight the field with user access value. Compare the field with current visit time.


texts: Theme template.php functions after bootstrap

texts:
I'm trying to print a drupal menu outside drupal. In order to achieve this I ran the bootstrap as follows:

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

And I render my menu as follows:

public static function getDrupalMenu($menuName) {
        $menu_output = &drupal_static(__FUNCTION__, array());

        if (!isset($menu_output[$menuName])) {
        $tree = menu_tree_all_data($menuName);
        $menu_output[$menuName] = menu_tree_output($tree);
        }
        return render($menu_output[$menuName]);
    }

Which is basically just a copy of the menu_tree function AND with menu_tree_all_data instead of menu_tree_page_data so I get all links no matter what page I'm on.

Everything works fine so far, my menu is printed, everybody is happy... but unfortunately my links are incorrect somehow. To solve this I've used a solution for absolute links as described here:

How to force absolute links on a menu tree in Drupal 7

So I use:

function mythemename_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], array_merge($element['#localized_options'], array('absolute' => TRUE)));
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

This works fine on my drupal site, but where I call the getDrupalMenu() after initializing the bootstrap it does not work (empty result, not even the original one). I probably have to set the theme or something, but I can't find what or where to do so.

Just to be clear: when I change the code in core (menu.inc) is works fine on both sites... it just gives en empty result when I override it in the theme.

Any pointers or solutions ?


texts: What is the difference between context layouts and the delta module?

texts:
I was recently introduced to the Delta module and I think it is fantastic. Specifically the way it works with the Omega theme in Drupal 7. It allows me to copy the theme settings and create layouts to load in context as a response. This is great, but as I went to enable the module on my system I ran across the context layouts module and am left wondering if I shouldn't just use the context layouts module.

So I am wondering if anyone can provide some insight into this. I will go ahead and check both out here in a minute, but I think they both do almost the same thing. I guess it really just depends on what restrictions on layout the context layouts module offers along with whether or not it can let me use the settings in the theme and modify those based on a context.

This also will be interesting to see if the delta module creates files or if it puts all of this into the DB. I suspect the latter, but am concerned about the former for packaging things up into features.


texts: Theme are different between different user

texts:
I grant permission of menu ['node/add'] to a certain role of users (which was only accessible by admin previously). Turns out that, these two types of users have different views of this menu (As you can see from the following two screen shots).

How can I theme the page for these two users in the same way? Or How can I change the theme for the non admin user?

-----------update-----------

If I don't want to use admin theme, where should I add my own theme?


texts: Disable field validation of custom line items when cart is modified

texts:
How to disable custom line item's field validation when line item is removed from cart?

My line item has a required field and if product/line item is removed from cart it still tries to validate it.
This causes form errors which isn't required.


texts: Weekly Gym schedule / irregular recurring Events / D7

texts:
I've been searching and trying for weeks now, but could not find a way to properly display a gym's schedule. Here is the setup:

atm there are 3 gym branches with their own unique schedule (but using one pool of classes)
each gym got its own node showing a schedule table/calendar
classes recur irregular e.g. Gym-1: "Zumba" each Mo 8-9am and Fr 6-7pm (but Gym-2 with different times)
tables only need to be editable by admins; no user interaction
table granularity should be 15 or 30 minutes (but only showing rows with at least one item)
also, on the front page there will be a block, showing the next class for each gym (day and time)

So I created one node for each class (e.g. "Bodypump", "Zumba",..) and added all kind of fields but can not work out how to show them in 3 independent schedules. I think it has to be 3 views but unsuccesfully tried TableField, multi-value date Fields with FullCalendar, Taxonomy,...  Is it actually possible to do this with existing modules? Pushing me in the right direction would be highly appreciated!

Note: I am not capable of programming my own modules, but at least i would know how things stand when this is becoming necessary. Also I am not a Drupal pro and might have missed the obvious.. Thank you!


texts: In Drupal 8, how do you add attributes to a link generated by the core Link field? (or, generally a render array with #type set to "link")

texts:
So I have a situation where I have a core Link field on a node. I wanted to style that link with custom attributes, so I created a field.html.twig override to do that, only to find that the link itself is printed elsewhere. There doesn't appear to be a template or theme hook for the link; given that the core Twig debug functionality doesn't report a child template being invoked.

I tried pulling the URL out directly and rendering my own link, but that class (Drupal\Core\Url) isn't on the Twig whitelist, so getting the URL out will just cause a WSOD. There doesn't appear to be an Attributes object that I could add things into.

I could use theme_preprocess_field to call Drupal\Core\Url->toString() directly and store it in another variable, but I'd be throwing out whatever attributes are generated by default. I'd rather participate in however Drupal is rendering this link directly; or, if it's not extensible, at least know how to replicate what core does.

(For the record, the solution recommended in another question of using theme_preprocess_field to write attributes into #options does not appear to work.)

EDIT: As requested, here is the code I tried for a preprocess hook to add attributes:

function MYTHEME_preprocess_field(&$variables) {
    $element = $variables['element'];
    if ($element['#name'] == 'field_extra_links') {
        $variables['items'][0]['content']['#options']['attributes']['class'][] = 'Button';
    }
}


texts: Can customizable products work out price based on the number of uploaded files?

texts:
I'm using Drupal Commerce and would like to develop an online photo printing service like shutterfly.com and snapfish.com.

I wonder if it's possible using customizable products to count each uploaded file/photo and charge accordingly? If not, what other way can I achieve this requirement?


texts: How to change google translator selectbox to normal links listing?

texts: I want to change google translator display layout from select box list to normal  links list.I'm using below code.  For more info http://screencast.com/t/3MPGGygRkX . Please help.


texts: Creating a "tag blacklist" for users on a view

texts: I'm looking to allow users to create a "blacklist" of certain tags on a site. My plan was to do this through adding a "Blacklisted Tags" field on the user entity, but I'm open to other solutions.  If an item is tagged with a tag they've blacklisted, it won't appear in a view.  Is there a way to do this using default views functionality? If not, what's the simplest way to achieve this?


texts: Show fields content node according to its taxonomy using views 3

texts:
I need to create a view block type and show only the title of my node and its image but they are related by their taxonomy.

The image is attached to the node.

The node has its taxonomy_field field.

I have two taxonomy vocabularies: products, services.

The block will be placed on pages where have as URL: "taxonomy/term/tid"
But these have their path URL alias, that is: " products/title-taxonomy "
Then, the block is configured to only in scrambled URLs such as " products/* "

When creating my view I have the following configurations:

Fields:
- Title
- field_image

relationships:
- Content: Taxonomy terms on node
- Vocabulary: Products

Contextual Filter:
- Content: Has taxonomy term ID (with depth)
- Provide default value -> Type: Taxonomy Term ID from URL -> Load default filter from term page

But, when I activate the block in the content region does not show me any results.
Change the setting of contextual filter by:

Content: Has taxonomy term ID
Provide default value -> Type: PHP Code -> return arg (2);
This value would only take the url: taxonomy / term / tid that is covered by his alias and would return the tid value.

But I get an empty result. Even in the preview of the view, if I put a value directly, does not generate any results.

What is it I'm doing wrong? Or need some more configuration?


texts: Exposing a type of field operation (flag lists) for search index view

texts:
I installed the flag list operations module which gives me the ability to do operations on my views results. But this flag list operations doesn't show up on my search index view as seen below.

I'm sure there is some parameter or variable that is set in the flag list module that is preventing this operation to show up on the search index view.

What should I be looking for in the flag list module code to enable this operation to show up in the search index view?


texts: Unable to attach third-party library to theme

texts:
I have a multi value media field on a content type and I want to display it as a slider on the node if more than one image is uploaded to that media field.I am using slick library for this purpose.
Defined the library in the libraries.yml file and then i changed the twig output of the filed template to get the desired html out as mentioned on the slick website - http://kenwheeler.github.io/slick/

theme name : bs

bs.libraries.yml

slick:
  version: VERSION
  css:
      css/slick.css: {}
      css/slick-theme.css: {}
  js:
    js/slick.min.js: {}
    js/slick.config.js: {}
  dependencies:
    - core/drupal
    - core/jquery

slick.config.js

(function ($, Drupal, window, document) {

Drupal.behaviors.bsSlickConfig = {
  attach: function (context, settings) {

    $('.responsive').slick({
      dots: true,
      infinite: false,
      speed: 300,
      slidesToShow: 1,
      slidesToScroll: 4,
      responsive: [
        {
          breakpoint: 1024,
          settings: {
            slidesToShow: 3,
            slidesToScroll: 3,
            infinite: true,
            dots: true
          }
        },
        {
          breakpoint: 600,
          settings: {
            slidesToShow: 2,
            slidesToScroll: 2
          }
        },
        {
          breakpoint: 480,
          settings: {
            slidesToShow: 1,
            slidesToScroll: 1
          }
        }
        // You can unslick at a given breakpoint now by adding:
        // settings: "unslick"
        // instead of a settings object
      ]
    });

  }
};

  } (jQuery, Drupal, this, this.document));

field--node--field-slideshow.html.twig

{{ attach_library('bs/slick') }}
{%
  set classes = [
    'slideshow__slides',
    'responsive',
    'field',
    'field--name-' ~ field_name|clean_class,
    'field--type-' ~ field_type|clean_class,
    'field--label-' ~ label_display,

  ]
%}
{%
  set title_classes = [
    'field__label',
    label_display == 'visually_hidden' ? 'visually-hidden',
  ]
%}
<div{{ attributes.addClass(classes, 'field__items') }}>
  {% for item in items %}
    <div{{ item.attributes.addClass('field__item') }}>{{ item.content
}}</div>
  {% endfor %}
</div>

the slider is loading but not working on the individual media but on the entire field as a whole.So all the three images in this case seem to slide at the same time.


texts:
Is anyone aware of a time-based rather than one-time login authentication module for Drupal?

We've discovered a problem where some email servers with advanced security tools will crawl through emails to verify the links in them. In so doing -- they invalidate the one-time login links, preventing some users from using them. Rather than verify on whether the link was clicked once, I want to invalidate it based on time. For example -- the link to login is valid for 1 hr from when it was generated.


texts: Generate a new password when a user account is activated and send an email with password

texts:
I am working on a web application using Headless Drupal 8 and Nuxt.js on the front. The app is to manage team members.
Member can register (via REST API) without setting his password and wait for the (ADMIN) or users with the (LEADER) role to activate his account.
ADMIN activates all types of users accounts from the drupal dashboard (/admin/people).
LEADER activates members accounts belonging to the same team from a front dashboard.
The LEADER can activate or add a new member to the team.
If a member has been added from front by LEADER it will be activated and a notification will be sent to the member containing their email address and a temporary password. Then, the member can keep or change his password later in his profile page.
I want to generate a temporary password when ADMIN or LEADER activates a member account and sends an email containing (email and the generated password).
I have used the rpt and genpass modules but these modules cannot do the job in a headless aproach.
How do I add a custom event listener when activating an account, generate a password and notify the member by email and password?


texts: How to use DS layout on page generated with views?

texts:
I have a site where products are shown in different categories using taxonomies. I then use a view that emulates Drupal core's handling of taxonomy/term to generate those pages. Now, in only one of these views pages I want to show a block to the left. Under Manage display for the page in question I have chosen a DS layout (2 column stacked fluid). But I cannot figure out how to get it to work.

I have saved the template in question with one of the suggested names (ds-2col-stacked-fluid--taxonomy-term--51.tpl.php), targeting a specific taxonomy term.
I have created a custom field (that shows my custom block) in the DS layout and I have placed that field in the right region and the main content in the left region.

The problem is that this DS template is ignored by Drupal. I assume that the reason is that I should change the template's name to one that targets the view instead? But when I look in the view's theming information there are no hints on how to target a specific taxonomy term or nid with a views display template.

Can anyone help me with some advice on how to reach my goal of showing a block to the left and the views content to the right on the page?

EDITED: As suggested by Baach I enabled theme_debug and this is the output:

<!-- THEME DEBUG -->
<!-- CALL: theme('html') -->
<!-- FILE NAME SUGGESTIONS:
   * html--taxonomy--term--51.tpl.php
   * html--taxonomy--term--%.tpl.php
   * html--taxonomy--term.tpl.php
   * html--taxonomy.tpl.php
   x html.tpl.php
-->
<!-- BEGIN OUTPUT from 'sites/all/themes/mysite/templates/html.tpl.php' -->

So I guess I will have to scrap my DS layout idea and just use the first suggestion above and adapt a html template for my specific page. That should work.


texts:
I am developing/testing some JavaScript functionality. Every change in the JavaScript code I make means I have to reload the page, and wait for Drupal to build the page from scratch, which I don't need at the moment.

Is there a way for telling the browser to reload that one file only?


texts: Best practice to change 403 page depending which page 403?

texts: In D7 I would like to display some cause for the 403 and that changes by path (and other factors but those are easy). I can think of a few tricks like using request_uri() to see which page we were on, originally but I wonder if there is a good practice already established for this?


texts: Behaviors/JQuery: What's the standard/convention in Drupal 7 for running Jquery code on event *OTHER* than DOM ready?

texts:
Searching online docs so far and I've found much about Drupal Behaviors running when the DOM is ready i.e. the ready JQuery function.

But what about for example if I want my JQuery code to run once all the images have loaded? Now, I could use the JQuery load function, but this is apparently not recommended to use such Jquery functions JQuery directly in Drupal but work within Behaviors instead - but these are no good to me if they only run on DOM ready event.

Thoughts?


texts:
Is it possible to login to Drupal with just a number?

Use case is a kiosk where users have a nfc tag.
So my idea was to hide the input field an use the number retrieved from the nfc tag to identify the users.

The kiosk is only used internally and there would be no keyboard just a touchscreen.

Thanks


texts: how to create hook for send email to profile2 type user

texts:
In my project there are two types of user.Using profile2 module i creates 2 profiles.
1) normal user
2) Lawyer

So i have to send promotion email to lawyer after registration.
i created following rule.

1) Event
 - After saving a new profile

2) condition
 - user has roles

a]After selecting they ask for  Data selector. i don't know what i select for my lawyer account

b]i select "lawyer" Roles

c]match roles - all)

3) Event
 In event i select send-email

a]email function $to - how i can put current user registration email

b] body is static

c] subject is static

I am really confuse. Can i create hook for send email to lawyer after registration.


texts: How do I get the current node from a Block module?

texts:
I'm looking to create a block that renders differently, depending on the content (metadata, really) of the node in which it is embedded.

The “Title” block is a good example of what I'm trying to do, I think. When you put “Page title” in a section (from the Structure menu), it displays the title of the node being displayed.

I'd like to do something similar. The end goal is to read the workflow state data from the node in order to provide large visual clues to readers that the document they are reading is approved/unapproved/et cetera.

There are some other similar ends to which I may put this technique as well, provided I figure it out.

Here's what I have:

/**
 * Provides a 'Workflow Block'.
 *
 * @Block(
 *   id = "workflow_tag_block",
 *   admin_label = @Translation("Workflow Block"),
 * )
 */
class WorkflowTagBlock extends BlockBase implements ContainerFactoryPluginInterface {
        protected $node;

        public function __construct(array $configuration, $plugin_id, $plugin_definition, $node) {
                parent::__construct($configuration, $plugin_id, $plugin_definition);

                $this->node = $node;
        }

        public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
                return new static(
                        $configuration,
                        $plugin_id,
                        $plugin_definition,
                        $container->get /*... something here, I think. I need this to be the node I'm rendering. */
                );
        }

        /**
         * {@inheritdoc}
         */
        public function build() {
                // do things with $this->node;

                return [
                        '#markup' => $this->t('Here Be Dragons! '),
                ];
        }
}

Obviously, there's an important line I don't have complete in there. The most obvious attempt would be: $container->get('request_stack')->getCurrentRequest()->get('node'). But that returns the WorkflowTagBlock object itself, not the primary content node.

I'm aware that multiple nodes might be rendered on the screen at once (for example, in a list), so I can't just try to snag the node id from the uri or anything like that.

This is done in other places, so surely there's a way to do it. How?


texts:
I had security_review warning for boost cache folder.

I've changed cache folder location to "sites/default/files/cache"

And now I have no warning.

Is this solution correct and safe?


texts: How to remove all attributes displayed for a field?

texts:
We are looking for a way to remove all the attributes for one or more fields (if not all) when they are displayed. There is a way to do this using Twig template by removing {{ attributes.addClass }} in any twig template that has <article {{ attributes.addClass }}>, but that requires for us to do this with all fields and any twig templates.

The goal would be to have a settings globally to remove the attributes, but we have been unable to find a module that does this.

How would we without modifying twig templates, accomplish this situation?

We have a way to add custom attributes on a as needed basis.


texts: How to share content and files with other users within the site (not in facebook or other social media)?

texts:
Users would like to be able to share content with other users within the site (not on Facebook or any other social media).

For example, if I read a blog that I like and think my colleague would be interested I could click 'SHARE' and send it to another user's profile or work e-mail address. Or tag someone? This would require a notification to the user that they have shared or tagged in something.

It would be great to be able to do this with blog posts, files, photos, and videos. "


texts: How to remove the thousands separator in the Filedepot module?

texts:
I'm using the Filedepot module (7.x-1.x-dev), and I have a problem with the file navigation for more than 1000 files.

I have changed the thousands separator from comma to none for parent folder, folder ID and node ID. I don't find any thousands separator option for the folder name. It works fine for filedepot/folder/1110, but not for a path like filedepot_download/1%2C235/1%2C110.

Where do I change it for filedepot_download, in the view settings?


texts: Dynamic Views Pages - How to add in meta tags to these generated pages?

texts:
I have 1000s of dynamically generated views pages using contentual filters. I want to be able to take certain keywords from these generated pages and add them to the on page meta tags. Currently I do not have any metatags on these pages. Is there a module that can add such a functionality that can inject it into a view?

If there is no such module, do you think the best way would be to create a custom tpl just for these dynamic pages and output these keywords on the html.tpl.php template?


texts: How can I remove self-closing source tags when rendering HTML markup?

texts:
I use this markup in a node body.
<video>
  <source src="myvideo.mp4" type="video/mp4" />
  my title
</video>

The following markup is instead rendered in the node view.
<video>
  <source src="myvideo.mp4" type="video/mp4" />
    my title
  </source>
</video>

</ source> is added to the markup, and renders the full HTML not valid.
How can I avoid </ source> is added?


texts: How to implement a jscript for displaying custom ads

texts:
I am very much a beginner with scripting, drupal theming, etc and I cannot figure out how to deal with the following "problem":

I have signed up my site with a media network, which will handle all the ad revenue making.
They have given me a custom .js script and shared the following generic instructions:

upload the .js script to the website - That I can do. :)
paste <script type="text/javascript" src="path to script/scriptname.js"></script> into the <head></head> area of all pages on the website. I guess this means editing the page.tpl.php file of the theme I am using to add this piece of code. However, I do not know how to do this, in a way that works well, without breaking the theme and how the website is displayed.
call the script into specific ad areas/blocks using something similar to this: <script>scriptname.display(options = {'width':635,
'ad_width':190,
'max_ads':3,
‘descFontSize':15,
'linkFontSize':12,
'linkFontColor':'999999'});</script> Here, I am not sure if it is enough to simply copy/paste this code, while using the correct name of the script file.

The trouble is, these guys are used to working with WordPress and they won't advise me on how to set things up in Drupal. So... I appreciate any advice you can give.

PS: I am using the latest version of Drupal 7.


texts:
I am setting a website up that will house multiple language schools, so I am mainly dealing with:

Individual language schools
Language courses

I set up a content type called ‘Schools’ and have fields on this that are unique to a specific school, example:

School Name
School Location
Tel no and contact details
Description of school

I then used entities for these things that are also unique to a school but there are quite a few of them, so I thought I’d be better with entities, then use inline reference entity fields on the school nodes (is this correct?):

Types of accommodation
Activities
Facilities
Image Gallery

Now I have come onto adding courses, there is generally a theme for these at the top level such as: ‘Intensive English’ then each school has various classes, so you mght have ‘Intensive English’ MORNING or ‘Intensive English’ EVENING. Now I don’t want to create taxonomies for this classes as I’ll have URLs that don’t have anything on them, I’d have a table with the various classes in it. But the whole website needs to be searchable.

My question is, what do I need to do for courses? I used entities but now can’t create a view that shows the nodes referencing the schools nodes and place it on the taxonomy parent: General English, Intensive English etc. Anyone got an pointers on what I should do and if I have set this up correctly?

I am struggling to create a view that shows a course page and then the schools that offer it, despite creating a reference to it, as in the image. Tried everything with contextual and relationships.


texts: FontAwesome character added via CSS only appears when logged in

texts:
I'm pretty new to Drupal and CSS; I'm stumped with this issue. I have a FontAwesome camera character that I've written to appear before my caption div in Flexslider. Here's what I have:

div.flex-caption:before {
    content: "\f083";
    font-family: fontawesome;
    margin-left:10px;
    padding: 10px;
}

This works fine when I'm logged in as a user to the site, but the icon doesn't appear if I'm not logged in to my Drupal site. Not sure why—any ideas? I'm using Drupal 7.31

Edit: Just to clarify, all other FontAwesome characters are working fine. It's just this particular bit of code that isn't working.


texts: Is there a way to call "access callback" with parameters?

texts:
I have:

function hook_menu()  {
    $items = array();
    $items['experiment-2'] = array(
        'title' => 'Experiment 2',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('experiment_form'),
        'access callback' => 'user_can_access_experiment',
        'file' => 'includes/experiment-2.form.inc',
        'type' => MENU_NORMAL_ITEM,
      );

    ...

This will call:

function user_can_access_experiment() { }

But I want to be able to call it something like:

function user_can_access_experiment($experimentID) { }

And then somehow let hook_menu call the function as user_can_access_experiment(1) or user_can_access_experiment(2) or whatever.

Is this possible?


texts: How can I use Rules to 'Set a Data Value' on a node's field WITHOUT updating that node's 'updated' timestamp?

texts:
I am using rules to set a data value of a field on a node. Works great!

BUT, when the rule is triggered, the node's 'updated' timestamp is changed. In my particular application, I do NOT want this to happen. I totally understand why this behavior might be desired by some (most), but in my case I don't.

Is there any way to prevent the 'updated' timestamp from being updated when rules is used to set/change the value of a field on that node?

Here are the nitty gritty details of my application:
I have two node types: Parent & Child
The child node includes an entity reference field to relate it to its parent node.
When a child node is created or updated, I use rules to change a field value of it's parent node.
I got that all to work great, but, when the rule is triggered, the parent node's 'updated' timestamp is changed to the current time, which I do not want.

I also posted this question to the Rules issue queue on d.o:
https://www.drupal.org/node/2796899


texts: Is there a way to list permissions for a given module?

texts:
Using Drush 9, I am trying to automate the creation of a role and I need to assign permissions to it. I see that I can use drush role-add-perm to do the assignment itself, but I can't find a command to actually give me the permissions supplied by the enabled modules.

It looks like this was doable in older versions of Drush, but I'm not sure Drush 9 has equivalent commands.

Thanks!


texts:
When a user is creating a node, is it possible to auto generate an accordion based on a field group or field collection? I want the user to enter the title(clickable to expand and show body) and body of their accordion(s).

I see field_group and bootstrap_field_group, but both require me to add the title for example and then give the body of the accordion based on another field... That is admin specific. I'd like to give the user the flexibility to create their own title for each accordion item.


texts:
How is it possible to embed videos using the YoxView module in Drupal 7?
Alas, this module doesn't seem to have documentation on how to use it.

It seems ALL possible on the YoxView Official Website.
I've managed to use its image viewer easily and perfectly, but I got no clue on using the video embedder.


texts: How to setup Recaptcha on pages cached by Varnish?

texts:
On a site where a contact form is displayed at the bottom of each page, I implemented Varnish caching. To do so I had to deactivate Recaptcha to avoid 'no cache -must revalidate " headers.

I tried other antispam solutions such as Honeypot or Botcha, but Honeypot is not efficient (at least with time limit  disabled), and Botcha also invalidates cache. I'd really prefer to go on with Recaptcha

I tried also Boost Captcha dev version : as per this related Varnish issue, it should be quite straightforward to make it work for Varnish. But this doesn't help, cache  is still invalidated.

Did anybody could make Recaptcha work with Varnish ?


texts: How to track users actions on a form in my website

texts:
I read some post about "how to track..." but i didn't find my answer. I don't want to track the user loggin or how many time a user click on a link but what i would like to accomplish is:

Track my user (anonymous or authenticated) to know if they failed to fulfill a form (failed = quit before submitting the form)
Have a rate about each form who tell me, for example : 30% of users who begun the register form, stopped before submiting
And more, knowing which fields were fulfilled before he quit.

My purpose is to help me to:

Understand which process, forms are misunderstood in my website
Maybe, knowing exactly which fields in my form (which label) are misunderstood (thanks to the fact that i could know which fields were empty when he quit)

I'm not a pro of Google analytic but i don't think so he can do that.
What is the better approach for me to do that?

Thanks,


texts:
I cant find the answer to my question by googeling or in the documentation for the theme but im sure ive heard it exists. Does the Omega theme give you a CSS grid to work with?

So if you wanted to customize a tpl file and have 2 colums, one twice the width of the other, could you just write some CSS a bit like this?

content here

more content here

Im happy to use standard classes but Im trying to avoid adding additional CSS, I would have thought the theme (as a grid based layout) would have classes I could use? Thanks


texts:
The main idea is updating prices via feeds. If SKUs are unique, we can update products using this parameter.

Unfortunaly module UC Feeds is able to create only new producs. How to modify UC Feeds for updating products ability?


texts: Trouble hooking blocks with theme templates

texts:
So I am making blocks and viewing the page source when they're displayed, and for instance one has the id="block-views-first-row-footer-links-block"

so I make templates called the following: none will work(yes I am clearing the cache)...I am using drupal 7.12

block--views-first-row-footer-links.tpl.php

block--first-row-footer-links.tpl.php

block--footer-links.tpl.php

what am I doing wrong here?


texts: Commerce catalog sorted by taxonomy term

texts:
I have a commerce shop with a bunch of products sorted by taxonomy terms with descriptions. Each product display is tagged with one category.
Now I want to display them in on view, sorted by the taxonomy terms.

It should look like this:

Category1
  Description

  Product1
  Product2

Category2
  Description

  Product3
  Product4

I read about some solutions but they required the use of the table formatter, but thats no solution because in need to display node teasers to use the add to cart widget. What is the easiest way to achieve this?
I'm not afraid of coding but have no experience with views.

Greetings MrPinkey


texts:
I'd like to customise the CKEditor config, by using the removePlugins setting to disable the elementspath plugin, so that body p etc. isn't displayed in the status bar (here's a similar, old question for D7).

I created the following CKEditor plugin, which returns an additional setting via the getConfig() method.  It has no effect on my editor fields (I've verified the plugin ID is being matched).

What's the right approach - if not this - for a config change, given I'm not loading a new plugin JS file or adding buttons?

<?php

/**
 * @file
 * Definition of \Drupal\ckeditor_remove_elementspath\Plugin\CKEditorPlugin\RemoveElementsPath
 */

namespace Drupal\ckeditor_remove_elementspath\Plugin\CKEditorPlugin;

use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;

/**
 * Defines the "Remove Elements Path" plugin.
 *
 * @CKEditorPlugin(
 *   id = "remove_elements_path",
 *   label = @Translation("Remove elements path"),
 *   module = "ckeditor_remove_elementspath"
 * )
 */
class RemoveElementsPath extends Pluginbase implements CKEditorPluginInterface {

  /**
   * {@inheritdoc}
   */
  function getDependencies(Editor $editor) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  function getLibraries(Editor $editor) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return false;
  }

  /**
   * {@inheritdoc}
   */
  public function getFile() {
    return false;
  }

  /**
   * {@inheritdoc}
   */
  public function getButtons() {
    return [ ];
  }

  public function getConfig(Editor $editor) {
    return [
      'removePlugins' => 'elementspath',
    ];
  }

}


texts: Display a Media Entity Image from other (referencing) node in a Twig template

texts:
Seems that all found in the Internet does not work for my case. :/
In general, I need to display an Image and a Project, referenced by the node that has a reference field to my node.

I have:

a node of CT Idea (here I want to display my content)
a node of CT Example, which has:

1) a ref field to Idea
2) a ref field to a Media, Image
3) a ref field to a CT Project

I want to display Examples on an Idea page, each Example displays:
Description, Image, Project link

I've managed to display the Description, but can not display Image and Project.

Here is the code

in the *.theme file:

function showcase_lite_preprocess_node__idea(&$variables) {
  $current_node = $variables['node'];
  $current_node_id = $current_node->id();

  $query = \Drupal::entityQuery('node');
  $query->condition('type', 'example');
  $query->condition('status', 1);
  $query->condition('field_example_ideas', $current_node_id);
  $nids = $query->execute();
  $relatednodes = Node::loadMultiple($nids);

  if (!empty($relatednodes)) {
    foreach ($relatednodes as $related_node) {
      $related_node_image = $related_node->field_example_image->value;
      $related_node_description = $related_node->field_example_description->value;
      $related_node_project = $related_node->field_example_project->value;

      $variables['related_node_image'] = $related_node_image;
      $variables['related_node_description'] = $related_node_description;
      $variables['related_node_project'] = $related_node_project;
    }
  }
}

In the node--idea.html.twig file:

{% block content %}
    {{ content }}
    {{ related_node_description }}
    {{ related_node_image }}
    {{ related_node_project }}
{% endblock %}

This displays only the Idea content and the Example Description.

It seems to me that the problem is that the format of $related_node_image and $related_node_project does not correspond to what Twig is expecting. But I can not check what is inside the variable, because Kint gives an error of memory limit.

Drupal version: 8.5.3.


texts: How to use the Elements module to make $form['element'] = array( '#type' => 'number' );

texts:
As Drupal 7, core field doesn't support HTML 5 form elements.

How can I use the Elements module from Form API to make the it works below?

$form['element'] = array(   '#type' => 'number' );


texts: D7 Simple form with an items catalog grid table

texts:
I need a form with a simple items catalog, user will enter quantities for each item and it will auto calculate sub total and total using javascript.

I am looking something like this:

Name: _

Email: _

Address: _

please select your items:

ID | Name   | Price | Quantity | Sub Total

1  | Item 1 | $10   | [_]  |

2  | Item 2 | $10   | [_]  |

3  | Item 3 | $10   | [_]  |

Total               |

[Submit]

Is there some module available to develop this kind of form, or I'll have to develop some custom module? I tried with Webform module but with no luck.

Thanks


texts: Custom tokens breaking on node save with "node entity cannot have a URI" error

texts:
I'm getting a crash on node save when my node contains a custom token.  I'm using the Token Filter module to display tokens in node content.

To make the tokens I followed this tutorial, which is similar to the Token documentation.

Now, with Drupal 8.8, when I save a new node that contains one of my custom tokens, I get a WSOD with this error:

  Drupal\Core\Entity\EntityStorageException: The "node" entity cannot
  have a URI as it does not have an ID in
  Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of
  core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

But the real error appears to be from token:

Drupal\Core\Utility\Token->generate('ebook', Array, Array, Array, Object) (Line: 196)
Drupal\Core\Utility\Token->replace('
Test [ebook:custom-type] 2

', Array, Array, Object) (Line: 130)
Drupal\token_filter\Plugin\Filter\TokenFilter->process('
Test [ebook:custom-type] 2

', 'ja') (Line: 118)
Drupal\filter\Element\ProcessedText::preRenderText(Array)
call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', 'silenced_deprecation', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)

Weirdly, if I remove the token from the body field when I save the node, the node saves properly-- and then I can edit the node and add the token back in without any error. The error only occurs when the node is saved and it has a token in it.

Drupal tokens like [site:name] work fine; it's just my custom token that causes an error.

Here's the relevant code:

/**
 * Implements hook_token_info().
 */
function MYMODULE_token_info() {

  $ebook_type = [
    'name' => t('Custom Tokens'),
    'description' => t('Tokens to make upgrading to D9 harder.'),
  ];

  $ebook['custom-type'] = [
    'name' => t("Custom type"),
    'description' => t('Apples or oranges'),
  ];

  return [
    'types' => ['ebook' => $ebook_type],
    'tokens' => ['ebook' => $ebook],
  ];

}

/**
 * Implements hook_tokens().
 */
function MYMODULE_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {

  $replacements = [];

  if ($type == 'ebook' && !empty($data['node'])) {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'custom-type':
          $replacements[$original] = MYMODULE_token_set_custom_type($data['node']);
          break;
      }
    }
  return $replacements;
}

function MYMODULE_token_set_custom_type($node) {
  $alias = $node->toURL()->toString();
  preg_match('(/.*/)', $alias, $matches);
  if ($matches[0] == '/apples/') {
    return "Apples";
  }
  else {
    return "Oranges";
  }
}

How do I resolve this?


texts: How can I display a node create form in a Panel pane?

texts: I'm trying to build a Panel page with two columns that are stacked side-by-side. I need the left hand column to display node/add/story, and the right hand column to display node/add/page. How can I do this?


texts: Adding “Unblock the user” option in Views Bulk Operations field

texts:
I have created a user based view and I used the Views Bulk Operations module, but I don't see Unblock user or something like that. I also want to show tree-based roles in the bulk operation options list.

How can I achieve this?


texts: Create a field (defined within same module) during module installation?

texts:
Having this code:

function mymybase_update_7200(){
    if(!field_info_field('field_timer_exam')){
        $field = [
            'field_name'  => 'field_timer_exam',
            'label'       => 'Countdown timer',
            'type'        => 'mymy_field_countdown',
        ];
        field_create_field($field);

        $instance = [
            'field_name'  => 'field_timer_exam',
            'entity_type' => 'user',
            'bundle'      => 'user',
            'label'       => 'Countdown timer',
            'settings'    => [
                'user_register_form' => 0,
            ],
            'widget'      => [
                'type'      => 'mymy_field_countdown_widget',
                'settings'  => [
                    'display_label' => TRUE,
                ],
            ],
        ];
        field_create_instance($instance);
    }

    if(!field_info_field('field_timer_final_exam')){
        $field = [
            'field_name'  => 'field_timer_final_exam',
            'label'       => 'Countdown timer',
            'type'        => 'mymy_field_countdown',
        ];
        field_create_field($field);

        $instance = [
            'field_name'  => 'field_timer_final_exam',
            'entity_type' => 'user',
            'bundle'      => 'user',
            'label'       => 'Countdown timer',
            'settings'    => [
                'user_register_form' => 0,
            ],
            'widget'      => [
                'type'      => 'mymy_field_countdown_widget',
                'settings'  => [
                    'display_label' => TRUE,
                ],
            ],
        ];
        field_create_instance($instance);
    }
}

Which i think it is ok, field get created when running in the hook_menu page callback for example, but during installation the fields does not get created.

There is no error in the watchdog nor in apache logs, the field does not exist in the user entity nor tables like field_data_field_timer_exam

The update get fired, at system table i can see the schema_version columna get updated for my module

What could be happening?


texts:
UPDATE: I know that I could accomplish this inside of a tpl.php file. But I would prefer to keep as much logic in the template.php file as possible, reserving tpl.php adjustments for markup. I have been informed that Drupal is NOT an MVC paradigm but an AOP, and I am trying to adapt to that as quickly as possible. But I feel that since I have already accomplished this IN the Template.php file that there is bound to be a 'Best Practices' way of doing this that I would like to adopt.

Currently, I have a node_field called field_unique_card. This is a Boolean field.
If field_unique_card == 1 then the title of the node needs to be something like this:

$title = '* ' . $title;

The way I am currently doing it is as follows:

UPDATE: I just remembered the better way of (expr1)?(expr2):(expr3); so I updated my preprocess function.

function theme_preprocess_node(&$variables)
{
    ...
    $variables['title'] =  $variables['field_unique_card'][0]['value'] ? '*' . $variables['title'] : '';
}

I am wondering if this is 'Drupal Best Practices' or if there is a smarter way? I ask because this only affects the nodes when they are displayed as a field. But on every node display there is an additional output of the Node title that happens at the top of the page. I can't figure out how to make it so that the title shows the * there as well.

Any help would be greatly appreciated.


texts: Migrating only articles with a specific taxonomy term

texts:
In the source D7, i have a content type 'article' containing a reference to a 'category' taxonomy vocabulary term.

In the target D8, I have a content type 'article' as well, but i only want to import those nodes whose 'category' reference does not equal 'interview' ('interview' is one of its terms).

Also, in the target D8, i have a content type 'interview' to which i want to import all D7's 'article' nodes whose 'category' reference equals 'interview'.

Any ideas how to condition this?


texts: Update image in image widget (automatically upload?) on another ajax reference field's autocompleteclose event

texts:
So I have a few fields that are automagically populated when an entity reference field is 'autocompleted'. Text and Image data (path, etc)

...field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
    $element['target_id']['#ajax'] = [
      'event' => 'autocompleteclose',
      'callback' => 'ajax_callback',
    ];

This is not an issue with text, but how do I update my image-widget (upload field) with a new image path and automagically upload?

...function ajax_callback(array &$form, FormStateInterface $form_state) {

// For text field this is pretty straightforward.
$response->addCommand(new InvokeCommand('input[name="field_....[' . $delta . '][subform][field_..._name][0][value]"', 'val', [$text]));

Is it possible to pass a path and filename to an image upload input(image-widget) and maybe mock .click() (or something) to trigger an automatic upload when selecting said field reference autocomplete?

Use case (total of 3 fields):
User completes autocomplete field and two additional fields, say description and image (upload input) are automatically populated/image uploaded. (But I can go back if the user wants and update the image (separately) using normal options on the image upload input, if needed.)


texts: How to create a Drupal database on the server if you only have access via an FTP client

texts: I am a bit confused about how to set up server database,because my host provider(is a university site),only provided me with a ftp client username and password. I don't have access to phpmyadmin.:/


texts:
i'm trying to create a module that adds a 'new' class to a row based on the date it was published.

So i thought of doing something like

if ($data > 10 days ago){
  $this_row addclass new
}

But whats the best way to do this? I would like to put this in a module so i can simply turn it on and off and avoid problems with template files from ds.

I can only find a way using hook_views_pre_render to add a class to all the rows, but nothing about adding it to one specific row. Maybe i need to use another hook?


texts: How can I create a view to display a secondary tab on a node?

texts:
Using views I can create a page with the nid as context and place a primary tab alongside the "View" and "Edit" tab on a node. How can I move it to the seconday tab on the "View" page?

e.g. What I can get

What I need


texts:
I have a View block. I can print the content with views_embed_view function, passing $display_id, contextual filter, etc.

Now I want the user to click on a point in an image, and with Javascript, show the block in a div. So when the user click on different coordinates of the image, I show different product details in that div.

This should be possible to accomplish using Ajax ( $(#div-id).html() or div_id.innerHTML ), but my limited experience with Ajax is to retrieve a JSON formated data, not a full HTML block of a View.

How could I get it working? Is it possible at all?


texts: Drupal 8 Webform - Pass submitted value from one webforms to another

texts:
I have two webforms on my Drupal 8 website. When a user submits the first webform, I have the confirmation redirect set to a second webform. I would like to populate one of the fields in the second webform with one of the submitted values from the first form. I have it set up as two separate webforms as some users will by-pass the first form and go directly to the second webform where they can manually enter the content into the field I need populated. Any idea how I can achieve this?

Thanks

F


texts: How to print multi-value link image CCK field in template?

texts:
I have a multi-value CCK field set up using the Link Image Field module, and I need to print all of the images (linked) on the content page. I used the code below to print the images themselves, but cannot figure out how to wrap each image's link around each image.

                <?php if ($node->field_day_option_buttons[0]['filepath']): ?>
             <?php
                foreach($node->field_day_option_buttons as $image) {
                 if (file_exists($image['filepath'])) {
                     print theme_imagecache('my image cache preset name', $image['filepath']);
                    }
                  }
              ?>
            <?php endif; ?>

Can anyone provide input on how to accomplish that?

Thanks!

EDIT
Here is the info placed on the page when I run a print(r) on that cck field:

Array (
  [0] => Array (
    [fid] => 347
    [uid] => 1
    [filename] => days-5.png
    [filepath] => sites/default/files/days-5_0.png
    [filemime] => image/png
    [filesize] => 440
    [status] => 1
    [timestamp] => 1366038083
    [list] => 1
    [data] => Array (
       [alt] => Alt Text
       [title] => Title Text
       [url] => http://www.mysite.com
       [target] => _self
    )
    [nid] => 18
  )
  [1] => Array (
    [fid] => 348
    [uid] => 1
    [filename] => days-20.png
    [filepath] => sites/default/files/days-20_0.png
    [filemime] => image/png
    [filesize] => 506
    [status] => 1
    [timestamp] => 1366038108
    [list] => 1
    [data] => Array (
       [alt] => Alt Text
       [title] => Title Text
       [url] => http://www.mysite.com
       [target] => _self
     )
    [nid] => 18
  )
)