texts: What hook can I use for post-save actions?

texts:
I've found several posts with this same question, but the answers always diverge to some other topic or they don't work for my needs.

After a node is saved, I want my custom module to insert a row into one of my custom tables which contains the nid of the new node. When hook_node_submit is called, the nid doesn't exist yet. hook_node_insert does have the nid, but only gets called the first time the node is saved, but I potentially need to take action each time the node is saved.

My plan is to separate my functionality into its own method and implement both hooks, but I'm trying to learn to do things properly with Drupal and so I'm wondering if there is a hook that actually fits with my requirements.

Is there a hook which is called every time a node is saved and called AFTER the save is complete?


texts: Views slideshow - 3 items per slide - how to center them?

texts:
I've been trawling the web on and off for months searching for an answer to the following:

I'm using Views Slideshow to show a series of logos in rotation. I have set there to be 3 items per slide in the slideshow settings. What I would like is for the three logos to be centred - i.e. an equal amount of space to either side of the logos. At the moment, they float left and I cannot for the life of me find the right CSS to do this, or where to add it.

I would really appreciate it if someone from the community could take a glance at the logo slideshow at the following url:

http://eunic-global.aptalops.com/

Please note that's it's the rotating logo carousel at the bottom of the page I'm having trouble with, not the slider under the main menu.

Best wishes,
A~


texts: Problem with db_select not returning records sometimes

texts:
Works:

$rows = db_select('notification_queue', 'nq')
    fields('nq', array('created_time', 'uid', 'notification_type', 'delivery_method','latest_time', 'earliest_time'))
    ->groupBy('uid')
    ->groupBy('notification_type')
    ->groupBy('delivery_method')
    ->addExpression('COUNT(*)', 'count')
    ->execute();

Does not work:

$rows = db_select('notification_queue', 'nq');
$rows->fields('nq', array('created_time', 'uid', 'notification_type', 'delivery_method', 'latest_time', 'earliest_time'));
$rows->groupBy('uid');
$rows->groupBy('notification_type');
$rows->groupBy('delivery_method');
$rows->execute();

I'm testing that something is returned with a simple foreach loop:

foreach($rows as $row) {
    msg($row); //msg is a simple wrapper for drupal set message
}

The reason I need to do things the second way is that I have to use addExpression and it won't work if try and use it in the first way.

I've tried this:

$rows = db_select('notification_queue', 'nq');
$rows->fields('nq', array('created_time', 'uid', 'notification_type', 'delivery_method', 'latest_time', 'earliest_time'));
$rows->groupBy('uid');
$rows->groupBy('notification_type');
$rows->groupBy('delivery_method');
$rows->addExpression('COUNT(*)', 'count');
$rows->execute();

And I've checked that the resulting query is correct (it is, I've tried using it with MySQL directly and it does exactly what I want). However, I can't get access to the rows using Drupal.

What am I doing wrong?


texts: How to make scheduled Feeds importers run consecutively?

texts:
I have two Feeds importers that need to run in a specific order. For example:

1) Importer 'Films' imports all the films showing at a cinema, creating 'film' nodes.

2) Importer 'Showtimes' imports the show times for each film, creating 'showtime' nodes.

Both importers are scheduled to run every day. 'Showtimes' must always run after 'Films' is fully imported, as it creates node references to film nodes.

Things I have tried:

Using Rules instead of Job Scheduler. I created a custom rules action using this code:

while (FEEDS_BATCH_COMPLETE != feeds_source('my_importer_id', $node->nid)->import());

I created a rule that triggers on cron with two actions: import films, import showtimes. This kind of works but when I look at the newly created nodes, showtime nodes are being generated before all the film nodes are created. So I guess rules actions aren't processed sequentially...?

Using Feeds Rules to chain one import onto another. Feeds Rules provides a 'after Feeds import' rules event.

So I tried creating a rule that triggers 'showtimes' importer (using my custom action above) after 'films' importer has run. But I ran into a problem applying a condition on the rule provided by the module. I'm not convinced this is the best method anyway.

Thanks


texts: Use Arrays in Twig Template from Custom Block

texts:
I'm attempting to use arrays in a twig template from variables in a custom block.

In my custom block I have

public function build() {
    $query = \Drupal::entityQuery('node')
        ->condition('type','product')
        ->sort('created', 'DESC');

    $nids = $query->execute();
    $i = 0;

    foreach ($nids as $nid) {
        $node = NODE::load($nid);
            $imageurl[$i] = $node->get('field_product_page_display')->entity->getFileuri();
            $title[$i] = $node->get('field_title')->value;
            $imageurl[$i] = str_replace("public://", "", $imageurl[$i]);
            $i += 1;

        }
    return array(
        '#theme' => 'product_display',
        '#imageurl' => $imageurl,
        '#product_title' => $title,
        );
}

In my mymodule.module file I have

function mymodule_theme($existing, $type, $theme, $path){
    return array('header' =>
        array(
            'variables' => array(
                'header_title' => 'Default Title',
                'header_size' => 'h1',
                'text_align' => 'center',
                'uppercase' => FALSE,
                'grid_size' => 12,
                ),
            ),
        'product_display' =>
            array(
                'variables' => array(
                    '#imageurl' => [],
                    '#product_title' => [],
                    ),
                ),
        );
}

in my product_display.html.twig file I have

{% for product in product_title %}
    {% for image in imageurl %}

                            {{ product }}

    {% endfor %}
{% endfor %}

I know for sure that my custom block.php file is able to retrieve the data properly because using Debug() on $imageurl or $title displays all the information. However using Dump() in product-display.html.twig shows the #imageurl and #product_title arrays as empty.


texts: How to let simplenews send email instantly without through cron?

texts:
I'm using simplenews and MIME mail in my drupal 7 site to send newsletter.

When I click send newsletter, the sending of newsletter is in pending status and waiting for cron to run and send email.

Is there any method I can send newsletter email directly without waiting for cron?


texts:
I created a template user-comment.html.twig to customize the rendering of the comments author.

I can not display the user account url:

user.url

does not work.

How to display the user's url in a template?

{#
/**
 * @file
 * Default theme implementation to present all user data.
 *
 * This template is used when viewing a registered user's page,
 * e.g., example.com/user/123. 123 being the user's ID.
 *
 * Available variables:
 * - content: A list of content items. Use 'content' to print all content, or
 *   print a subset such as 'content.field_example'. Fields attached to a user
 *   such as 'user_picture' are available as 'content.user_picture'.
 * - attributes: HTML attributes for the container element.
 * - user: A Drupal User entity.
 *
 * @see template_preprocess_user()
 *
 * @ingroup themeable
 */
#}

  {{ content.user_picture }}
  {{ user.label }}

    {{ content.utilisateur_statut_entity_view_1 }}
    {{ content.utilisateur_statut_entity_view_2 }}
    {{ content.utilisateur_statut_entity_view_3 }}


texts:
In node.tpl.php I am trying to get the raw value but the problem is that when I use render:

<?php print render($content['field_price']);?>

it does not just return field_image value but formats and outputs the whole image.

I need a way to get only the field's raw value. How can I achieve this?


texts: Referencing other nodes created by the same author

texts:
I have a site where members can sign up and post an article (standard content type) which I'll call STYLE A.
I now need to allow the members to create a different article (another content type) which I'll call STYLE B.

One of the fields within STYLE B will be a drop down list of all the article STYLE A's that this specific user has created. The user can then select one of the STYLE A's from the list.

I've tried using the reference and the entity reference modules but I can't quite get it. I've been able to create the reference field so that there is a dropdown of all STYLE A articles but these are not limited to that specific user.

Could anybody help me out. I've tried reading articles on relationships in views etc but it's not quite making sense.

thanks


texts: modify date token in View to extract only year?

texts:
We have a content type using a date field, in which the date is entered in the format mm/yyyy. An example entry might be 04/2016. In one particular View, we want to use only the Year value. It appears the token for this field is

[field_delivery_date-value]

In the Rewrite area for this View field, is there an operation that can be performed on the token in order to extract and display only the year value? Or would this need to be done in another way, not using tokens and the rewrite option?


texts: Problem creating nodes from XML using Feeds/ Feed XPath Parser

texts:
I'm trying to create nodes from an XML feed using Feeds XPath Parser.

Some of the data appears to import, but not all fields are being populated or populated correctly.

Here's a snippet of the feed:

<merchantProductFeed>
<script/>
<SCRIPT/>
<merchant id="2607" name="Business IT Online Office Shop">
<prod id="49194411">
<pId>571895</pId>
<text>
<name>
Avery afterBURNER Label System Software with Applicator 10 Inserts Ref AB1800 [24 Labels]
</name>
<desc>
Avery afterBURNER Label System Software with Applicator 10 Inserts Ref AB1800 [24 Labels].- Includes software, applicator, 24 labels and 10 inserts.- For Professional CD labels and inserts.- No Touch labels - unique design of the label sheets mean you can apply the label to the CD/DVD without touching the printed design or the adhesive.- 20 premium matt and 4 photo quality glossy labels.- The curved design of the applicator means the label is rolled smoothly onto the CD/DVD.- Inserts include a CD jewel case insert cover and tray (including spine) - allowing design and print in one effort.- The software contains over 2000 clip art images, 120 pre-formatted label designs and much more.
</desc>
</text>
<uri>
<awTrack>
http://www.awin1.com/pclick.php?p=49194411&a=953&m=2607
</awTrack>
<awImage>
http://images.productserve.com/preview/2607/49194411.jpg
</awImage>
<mLink>
http://www.businessitonline.com/avery-afterburner-label-system-software-with-applicator-10-inserts-ref-ab1800-24-labels.bprod?inctax=true
</mLink>
<mImage>
http://www.businessitonline.com/eCommImages/571895.jpg
</mImage>
</uri>
<price curr="GBP">
<buynow>15.56</buynow>
<delivery>5.95</delivery>
</price>
<cat>
<awCatId>68</awCatId>
<awCat>Software</awCat>
<mCat>Machines and supplies>Computer Software</mCat>
</cat>
<brand/>
</prod>

There are several more products in the document, structured in the same way.

In the feed importer, I've set the context as //merchantProductFeed/merchant/prod.

I have two fields to populate: 'title' (text) and 'cost' (decimal).

The XPath query I'm using for title is 'text/name' and the query for cost is 'price/buynow'.

When creating the nodes, the title field is populated with the correct data, but includes the  and  element tags.

The cost field doesn't get populated.

I can't see where my XPath query is going wrong, so I'm unsure if it's a problem with that or something that isn't happening properly elsewhere in the XPath Parser module. So far as I can see, the mappings are set up as they should be.

Can anybody see if my XPath queries are correct for the XML feed above?


texts:
I'm building a classified website, on which users can create ads using the custom content type I've created. Each ad has a category field which a reference to a multilevel taxonomy, and uses the  hierarchical select field type.

When a user creates an ad/classified, I'd like the UI to first ask the user to choose from the the top-level terms of the taxonomy, then from the child terms of what is selected, then the child terms of that, so on so forth.

Here's an example of what I'm trying to achieve:

I've already tried using Conditional Fields with Hierarchical Select, and Simple Hierarchical Select but neither have worked out so far. I'm trying to create something that's user friendly.

Any help is appreciated.


texts:
How can I create RSS channels for certain content type or it's subtype (certain taxonomy terms from that content type, so that users can effectively filter the information they need).

thank you


texts: Change field from Multi-Value to Single-Value

texts:
I have a developing a website with a reference term field with multi value. But after the client change the "rules" I need to change the field from multi value to a single value field, but the field as Data, lot's of data.

Is it possible to change from multi value to single value? (the field only as one value inserted and the real object is to use those values).


texts: What hook to alter the result of a view?

texts:
In a custom module, I have a custom entity for which a view shows the following values:

Contact is the ID of another entity (Person) containing some fields, such as Email. Adresse courriel is a Custom text field defined in the view.

What hook should I use to achieve the following task?

Query the Person entity with the Contact value to retrieve the Email field value
Update Adresse courriel in the view output


texts:
I have fieldsets in my form like this

$form['fieldset_1']['name']

and then

$form['fieldset_2']['name']

but when I submit the form and access the values item in $form_state there is only one name value - not as expected ['fieldset_1']['name'] and ['fieldset_2']['name']

can someone help how the form could be submitted and to have access to bot name values ?


texts:
I have 2 fields in a node and I'm trying to get the expired nodes set in "Start Date" and "End Date" field.

I'm using db_select to get the start and end date values.

How can I add a condition to check if the dates are in range?

Here's my current code:-

$query = db_select('node__field_end_date', 'ed');

$query->leftJoin('node__field_start_date', 'sd', 'sd.entity_id = ed.entity_id');

// Date values showing as a formatted date
$query->addField('ed', 'node__field_end_date', 'date_end');
$query->addField('sd', 'field_start_date_value', 'date_start');


texts:
I initially came across this error while I migrated my site from local server to live server.

Notice: unserialize() [function.unserialize]: Error at offset 83 of 108 bytes in variable_initialize() (line 935 of /home/ebemorgi/kog.church/includes/bootstrap.inc).

I followed #9 from this drupal post , then I found out that
the variable causing the issue was authorize_filetransfer_connection_settings_ftp.

I deleted the above variable but that hung up my whole website.

Then I deleted the content in the variable table and re-populated it.
Initially the error didn't popup but when I tried installing a new module at the live server the error
popped up with an new offset value. Again the villain is authorize_filetransfer_connection_settings_ftp.
The error which I am now receiving is :

Notice: unserialize() [function.unserialize]: Error at offset 32 of 121 bytes in variable_initialize() (line 935 of /home/ebemorgi/kog.church/includes/bootstrap.inc).

I have made sure that I have updated the ftp details in my mysql dump file before importing it to live DB.

I'm not sure if this issue is related to Core, but I don't honestly know under which product to list it.

Any help is appreciated.


texts: Programmatically change redirect after logout

texts:
I'm actually looking for a solution in Drupal 8 to change the redirection destination after visiting /user/logout page. I want to redirect the user on /user/login instead of home page.

Try this but not working, I'm still redirect on home page :

/**
 * @file
 * Contains my_module.module.
 */

use Symfony\Component\HttpFoundation\RedirectResponse;

function my_module_user_logout($account) {
  // We want to redirect user on logout.
  $response = new RedirectResponse("user/login");
  $response->send();
  return;
}


texts: Steps to create a geofield view proximity search for unrelated content

texts:
I am using geofield, leaflet maps and views to try to create a view of nodes of a content type B within a specified proximity distance of an origin specified in another content type A. A and B do not hold references to eachother. Content types A and B are not related and they do not hold entity references to each other so I cannot rely on views relationships to access fields from B in the context of A.
A and B both have geofield locations: A has field_origin and B has field_position.
Content Type A actually has three fields: field_view (type: viewfield) field_origin (type: geofield) and field_distance (type:decimal). I do not want to define a relationship between origin nodes (type A) and proximity nodes (type B).
This was my starting point but there are too few detailed steps to reproduce it and I think it assumes that the origin node has a relationship with the proximity nodes: https://www.drupal.org/project/geofield/issues/3149688
I cannot find a way to configure a proximity filter using either exposed or contextual filters to compare the origin of A against the position of B's.
I hope this is possible as I dont want to have to set up fixed one-many relationships between A and B so I can keep the views truly dynamic.


texts: How to include js library from /sites/all/libraries in twig template with attach_library?

texts:
According to https://sqndr.github.io/d8-theming-guide/libraries/libraries-and-twig.html, you can include a library within twig template to only load it on specific pages using {{ attach_library('theme/library') }}. This appears to be for libraries included in mytheme.libraries.yml.

Is there a way to use this to include a library from sites/all/libraries? It seems silly to add a library to my theme folder when it is already available globally.


texts: Passing taxonomy term through drupal_html_class() and use it as row class name

texts:
In a view I would like to use a excluded term reference field as source for the the row classname. But the values need to be sanitized by putting the term names through drupal_html_class(), otherwise the resulting classnames are not valid in every case.

How can I sanitize the values using a preprocess function?


texts: error 500: Premature end of script headers: index.php

texts:
Everything works except the /node/[nr]/edit page of only one content type page. And it's not for every page of this specific content type. Only one.

So let's say I have a content type "product" and created 5 nodes with that content type. Editing 4 of them works but for one the error 500 Premature end of script headers: index.php occurs.

I tried increasing the memory limit in the php.ini all the way up to memory_limit = 1024M (and restarted apache after that) but this changes nothing. Btw I'm using Acquia DevDesktop and the PHP version is 7.0.15. I also tried downgrading the PHP version (and there also increased the memory limit) but this won't do anything either.

Please help me, I'm incredibly thankful for every answer I can get!


texts: What to look / check for when can't connect to Vagrant VM made using the Drupal Vagrant project?

texts:
Using my Mac as the host machine, I followed all the instructions on the Drupal Vagrant project page at http://drupal.org/project/vagrant to get a Vagrant automated Virtual Box Ubuntu lucid32 Virtual Machine up and running with a Drupal 7 stack.

However when I try to use my browser to connect to the server, using the URL addresses stated in the instructions on the project page, it doesn't work.

(The same steps work when using Windows 7 as the host machine.)

The error message, for example, in Chrome is:
"Oops! Google Chrome could not connect to dev-site.vbox.local"

The Vagrant VM seems to be running OK and I can connect to it using vagrant ssh.

I also flushed the DNS cache using
dscacheutil -flushcache

and I tried all of the following:
http://drupal.vbox.local/
http://drupal.vbox.local/index.php
http://drupal.vbox.local/install.php
http://drupal.vbox.local/phpmyadmin

http://dev-site.vbox.local/
http://dev-site.vbox.local/index.php
http://dev-site.vbox.local/install.php
http://dev-site.vbox.local/phpmyadmin/

Mac OS 10.7.5. 4GB RAM. MacBookPro 2010.


texts:
I am Using elastic search APIS and exporting them as a rest view. Now I wanted to filter that data according to the roles and conditions based on the content data. I have done that using the view_query_alter HOOK but I am having trouble regarding the facets.
The facets show values from all data sets whereas i want it to be according to the filtered view data set.
Is there any easier way to do this or should i approach it with filtering the facets as well programmatically ?


texts: Adding token in the views header and footer

texts:
I have created webform and displaying the webform submission data using views. In above the submission data, I mean in the header, I want to display the data from the webform body field. I tried using adding the "Global: Unfiltered text" and placing the token of the body field. But when I view the page, it is not showing the body content instead of showing the token itself.

Please tell me how to use token of the webform body field in the header without using "Global: PHP"?


texts: Which kind of views style to use JS image effect?

texts:
I wonder which kind of views style do I choose to make a page like it can be done with masonry.

Actually I use Susy 2, and the example present items in div, actually I get items in a ul via views. Which is better?


texts: White screen of death: Fatal error: Allowed memory size of X bytes exhausted

texts:
I have a issue with my Drupal installation, for example:

when I enable or disable the modules, It redirects me to a blank page,
when I create a new content type and save it, redirects me to a blank
page,
when I add a new view and save it, it redirects me to a blank page,
when I try to clear the cache, it redirects me back to a blank page,
or in similar cases.

Basically all the confirmation pages redirect me to a white screen. When I refresh it again, it shows me the page. I tried to increase the PHP memory value but it doesn't help.

Are there any other solutions for this?

The error which I'm having:

  Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 8192 bytes) in sites/all/modules/views/plugins/views_plugin_localization_none.inc on line 1


texts:
How can I load a webform submission programmatically ?

I've tried : $webform_submission = WebformSubmission::load($sid);

but it return null.

I do this in a custom module call by an handler after webform submission.


texts:
I am using Drupal 7 with Services module (version 3.x). I want to add several nodes at once. When i try one it is okay.

{"type":"article","title":"Test article 1","body":{"und":[{"value":"test body!"}]},"language" :"und"}

But when I try something like this i can't

{"type":"article","title":"Test article 1","body":{"und":[{"value":"test body!"}]},"language" :"und"},{"type":"article","title":"Test article 2","body":{"und":[{"value":"test body!"}

Is there a way to make this happend?


texts: How do you implement a custom submit handler in hook_form_alter()?

texts:
I've been updating one of my Drupal 7 modules to 8 and I'm having an issue with my form alter. I'm adding a validation function and a submit handler. The validation function is getting called just fine, but the submit function is not getting fired. I'm wondering if this means there is a Symfony-style approach that needs to be taken to adding submit handlers to existing forms. I've done a lot of searching and I can't find any examples. Also looked through some work-in-progress D8 modules but I haven't really found any working examples there either.

Does anyone have any idea what the correct Drupal 8 way to do this is?


texts:
I installed Drush 7 using Composer, and I created a Drupal 8 running on XAMPP on Windows.

H:\xampp\htdocs\d8_test is the Drupal root.
Location of settings.php file is H:\xampp\htdocs\d8_test\sites\default\settings.php.

None of the drush commands are working. All are failing with the same error:

H:\xampp\htdocs\d8_test>drush pmi
Command pm-info needs a higher bootstrap level to run - you will need    [error]

to invoke drush from a more functional Drupal environment to run this
command.
The drush command 'pmi' could not be executed.                           [error]

Drush was not able to start (bootstrap) the Drupal database.             [error]

Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version        :  8.0-dev
 Site URI              :  http://default
 Database driver       :  mysql
 Database username     :  root
 Database name         :  d8_test
 PHP executable        :  php.exe
 PHP configuration     :  H:\xampp\php\php.ini
 PHP OS                :  WINNT
 Drush version         :  7.0-dev
 Drush temp            :  Z:\Temp
 directory
 Drush configuration   :
 Drush alias files     :
 Drupal root           :  H:/xampp/htdocs/d8_test
 Site path             :  sites/default
 Active config path    :  sites/default/files/config_MoeSD5C7JSguok
                          xrBh4-UuwT_r9_jk2Z59QKdN-j9Zx9DIgHBy2dH8n
                          1rGOeKNJpaAAxBi4PzA/active
 Staging config path   :  sites/default/files/config_MoeSD5C7JSguok
                          xrBh4-UuwT_r9_jk2Z59QKdN-j9Zx9DIgHBy2dH8n
                          1rGOeKNJpaAAxBi4PzA/staging

Contents of my settings.php

$databases['default']['default'] = array (
  'database' => 'd8_test',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

Note that host of my MySQL installation is 127.0.0.1 instead of localhost.

Also note that H:\xampp\php\ is added to my PATH variable, so php.exe refers to H:\xampp\php\php.exe.

The output of drush sql-connect is the following:

  mysql --user=root --password= --database=d8_test --host=127.0.0.1 --port=3306


texts: dump() not working in Drupal 8 (blank page, debbugging is enabled)

texts:
I want to use dump() in my .twig template (inside custom theme).

The problem is, when I place {{ dump() }} the page is just blank.

I have had:

Set twig.confing debug: true in services.yml.
Cleared cache.

The moment I remove {{ dump() }} everthing works.

After hours of googling I've found some information about mystery $settings['twig_debug'] = TRUE; here (I don't even have such line in my file, but adding it doesn't change a thing) and $twig = new Twig_Environment($loader, array(... (where to find it even?).

I work on clean & fresh Drupal 8 installation, turing debbuing on (step 1.) does include comments in source code (as it should) but use dump() once and all you see is just an blank page.


texts: how to import cck data from drupal6 to drupal7?

texts:
Now I have to upgrade to drupal7 website from drupal6, but there has been a new during the upgrade of the old site data, mainly CCK and taxonomy, what would I do for the way to the input of CCK in 6 to 7?
How can I do this?


texts: How to get submitted values on $formstate['values'] instead of $formstate['input']?

texts:
I was generating a simple form with below fields, but i am wandering why my field values are not storing in the $formstate['values'], but its in the $formstate['input'].. please have look into below code and correct me if i am doing something wrong.

function create_entry_form($form, &$form_state){
    $form['entry']['password'] = array(
      '#type' => 'password',
      '#required' => TRUE,
      '#default_value' => '',
      '#maxlength' => 15,
    );

    $form['entry']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('OK'),
      '#weight' => 100,
    );
    $form['entry']['emailid'] = array(
      '#type' => 'textfield',
      '#required' => TRUE,
      '#default_value' => '',
      '#maxlength' => 25,
    );

    $form['entry']['reqbtn'] = array(
      '#type' => 'button',
      '#value' => t('Request'),
      '#weight' => 106,
      '#executes_submit_callback' => TRUE,
      '#submit' => array('request_site_password'),
      '#limit_validation_errors' => array(),
    );

  return $form;
}
function request_site_password($form, &$form_state) {
    echo '<pre>';print_r($form_state);exit;
  }


texts: How do I add a class to HTML bookmarks generated by core?

texts:
I'd like to add a CSS class to HTML bookmarks generated by core. Examples of these bookmarks include:

I'd like to turn them into:

I'm unable to alter these in comment.tpl.php and it looks like theme_comment_view is unavailable in D7, so I'm kind of lost.

Background: I have a sticky header menu that's 60px tall and as such, HTML bookmarks are landing about 60px lower on the page than they should. An example of this is when you link to comment by ID, like http://site.com/article#comment-766013.

Thanks!


texts:
I have a blog content type which has a field for authors- (these are pull from a separate content type). multiple values are allowed.
i am trying to develop a module that will pull the authors email address and display it next to the authors name when ever a new author is added in the blog create form so users can edit the email on the fly while creating a new blog post.

i need some pointer as to the right hooks to use for these.
Thanks in advance.
See screenshot below of what am trying to archive


texts:
With Drupal 7, we have a custom module that displays a form that will work in both English and Spanish. Throughout the form we used t() to translate the text, and it works in all but two places. One is in the form when we declare a fieldset, and the other is the menu entry declaration (which isn't using t()). For the menu entry we have '[SiteName] Events' like this:

$items['sitename-events/register'] = array(
    'title' => 'SiteName Events',
    'page callback' => 'sitename_events_event_register',
    'access arguments' => array('view events'),
    'file' => 'public.events.inc',
    'type' => MENU_NORMAL_ITEM,
);

For the form, the element is declared like this:

// Personal Information
$form['personal'] = array(
    '#type' => 'fieldset',
    '#title' => t('Personal Information'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
);

Other pages are translating just fine, as well as other elements in the form, including the other field sets. What would cause these two entries to not translate, and is there a way that I can force them to translate since we're only going to support English and Spanish?


texts: Get URL path or node.id in views fields replacement pattern

texts:
I need to rewrite my view fields like:

     {{ title }}

But if I click on Add field (in my view), nid, or path are not available? I have to construct my  link attribute like above markup. But how do I render the URL path to the node?


texts: Programmatically executing a node search

texts:
Is it possible to programmatically execute a node search? Maybe via NodeSearch or Drupal\search?

The closest I could get was to programmatically do stuff such as:

\Drupal::service('search.index')->clear();

echo \Drupal::service('plugin.manager.search')->getCacheMaxAge();

Note that I don't want to use search_api but simply what Drupal 8 provides out of the box as a response to /search/node?keys=test. Also note that I don't wish to integrate via HTTP.


texts: Commerce line item views with fields from content node

texts:
I have some fields on content node (not on product variation)
like images, brand, and others that i want to show up in cart/order views
on edit view in advance>relationship, you can add product refference and that enables the option to add fields from product variations, but i cant find a way to add fields that are on the content node

In less words: i want to add fileds like image that are on the content type to cart/order views.

Found a good work around:

adding relationship you can obtain fields from product in views.


texts:
I have the bootstrap D7 Theme as a base themen. I added a new content-type for my header images and then create a bootstrap carousel using the bootstrap carousel view type.

Now I do get a carousel which seems to work fine but it looks crap, so I'd like to style it etc.

So accomplish this I though I could just "overload" bootstrap-carousel.tpl.php. But it doesn't work - it works for other template files though. Even worse: The original bootstrap-carousel.tpl seems to never be used. (Which porbably is the reason why my carousell looks totally unstyled).

What could be the reason for this?

Permission should be fine since it all the same and as I said, overloading other template files works.

Edit: For the carousel feature I use the bootstraps views module. I kind of expected that the tempalte files from the base theme kind of overwrite the ones from the module but it seems that isn't the case. why?


texts: Changing domain name for website still refers to old domain name

texts:
I have recently changed a domain name for a Drupal 6 website and am now experiencing weird behaviour. While I can view the front page of the website using the new domain name, any other pages or links I try to access refers to the old domain name. This is what you would see in the browser's url:

Home page:        mynewdomain.com
Interior page:    myolddomain.com/node

Shouldn't Drupal automatically know the new domain name? I have searched for a solution and can't find anything. What is causing this, and how do I fix it? This is really screwing up SEO rankings.


texts:
I have 2 groups of blocks in a view, I would like to join both of them in one view, showing the first block (I have the groups all linked one to the other).
I did download Views Field View but I can not manage the way to get it work, joining these 2 views.


texts: How to Force Visitor to Login after 3 Consecutive Download

texts:
My site serves downloadable files.

How can I force them to login/register after downloading 3 consecutive files?

Is there any available modules for this? If not, is there a sample script to start playing with?

I'm using drupal 7.


texts: how to create a view of entities and nodes

texts: I need to create a view which displays both entity type data and node data. Is this possible? I know how to create a view of either entities or nodes, but not together.


texts:
I tried to implement a time picker for a field opening hours. I used Bootstrap Date & Time picker and I set the FIELD TYPE to date, but I couldn't see any widget for BDT Picker in widget selection.

Then, I used jQuery UI Timepicker. The time picker is showing, but I can select only 0 for hours and 00 for minutes; all other cells are disabled. Also, the default time in the field is the current time.

What could the issue be?

When I select the date field type, the form has a date field with a full calendar. I need a field to pick only the time. How can I do it?


texts: Views date exposed filter by year in checkboxes

texts:
I have date field. In views I want to add the a date exposed filter.

This filter will only display year and we can select multiple years.

Just like this

I have checked the better exposed filter module, date view and I did not find any option to display them in checkboxes nor I find any option to select multiple dates like in the picture we can select multiple years.

With the date views and better exposed filter, I can display year only in select list.

Is it achievable? Any suggestion?


texts: Some tokens show as "missing name or description" in status report

texts:
Looking at a Drupal 7.43 maintenance project, my status report lists the following issue for Token 7.x-1.6:

The following tokens or token types are missing required name and/or description information:

$info['types']['date']
$info['tokens']['node']['url']
$info['tokens']['file']['size']
$info['tokens']['user']['url']
$info['tokens']['date']['custom']
The following token types are not defined but have tokens:

$info['types']['node']
$info['types']['term']
$info['types']['vocabulary']
$info['types']['file']
$info['types']['user']
$info['types']['current-user']

I have cleared cache a few times, hit update.php, and ran cron a handful of times. This message never goes away.

It is causing RealName to no longer work, path aliases are not being made, and page title / meta tags are not appearing (all are driven by Token).

What is causing this and how can I fix it? I am unable to replicate the issue locally with the same database and same code.


texts: Line items with "Inline Entity Form" module

texts:
https://drupal.org/project/inline_entity_form

  Requires integration code to be provided for each entity type that can be referenced.
  Supports the commerce_product (including Commerce AutoSKU integration) and commerce_line_item, node, taxonomy_term entity types out of the box.

I have two custom types, products and purchases. products is the master, purchases are individual line items.

I have tried following the instructions but no widget type "Inline entity form" is ever available and certainly no "purchases" editable via the "products" form...

There is some integration code required to make use but the docs also state it works out of the box for "nodes" as I have boldified above...are custom types not "nodes"???


texts: I want to develop the recommendation platform for job orders. In drupal there is the Prediction IO module but it is a sandbox project. How can I download it?


texts: Adding a radio button to a Drupal View page

texts:
Does anyone know how to 'inject' a radio button onto a Drupal View page?

I have an exposed filter that has nothing to do with a radio button but I want to add a radio button in front of the label in order to apply some additional AJAX to it.


texts:
I want to increase the node title length on Drupal 7, and as I guess I need to do just two things (theoretically).

Change the title column in the node table to acept more than 255 characters.
Alter the node creating/editing form to let the title field accept more than 255 characters.

I've done, #2 and trying to get #1 using this code:

/**
 * Implements hook_schema_alter().
 */
function my_module_schema_alter(&$schema){
    if(isset($schema['node'])){
        dsm($schema['node']);
        $schema['node']['fields']['title'] = array(
            'type' => 'varchar',
            'length' => 555,
            'not null' => TRUE,
            'default' => '',
        );
        dsm($schema['node']);
    }
}

If I check dsm() before and after, I can see a change, but I don't see the title column in the node table affected. Am I missing something or using the bad hook?

I also use this code to change the form on creating/editing nodes (this works well):

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, &$form_state, $form_id){
    if($form['#id'] == 'norma-node-form'){
        $form['title']['#type'] = 'textarea';
        $form['title']['#maxlength'] = 555;
    }
}


texts: How to display a node field value in a template file?

texts:
I added a custom field in the ‘article‘ content type.
I am using bootstrap as a theme.
I want to print that field value as a css class in the h1 element of every node of type : article

So I duplicated the page.tpl.php in my subtheme template folder and changed the h1 code from :

<?php print $title; ?>

to

<h1 class="page-header <?php print $node->field_custom_field['und'][0]['value']; ?>"><?php print $title; ?>

The problem is that sometimes sometimes I get this error message

    Notice: Undefined property: stdClass::$field_custom_field in include()
(line 157 of /home/frost/sites/all/themes/subtheme/templates/page.tpl.php).

I have basic php knowledge, so my guess is I need to add a condition saying that the custom field is only printed if the template file is called when an article content type node is being viewed.

How can I add this condition in the template file ?

Thank you


texts:
Does Google Analytics module tracks superuser 1 out of the box?

UPDATE: Found this in the .install file of the module. What does it basically say about user 1? Can anybody explain them to me? Does it track uid 1? Thanks.

variable_set('googleanalytics_roles', $roles);

// Upgrade disabled tracking of "user 1" to new logic.
if (!$track_user1 = variable_get('googleanalytics_track__user1', 1)) {
  variable_set('googleanalytics_custom', 1);

  // Load user 1 object, set appropriate value and save new user settings back.
  $account = user_load(1);
  $account = user_save($account, array('data' => array('googleanalytics' => array('custom' => 0))), 'account');
  $messages[] = t('Disabled user specific page tracking for site administrator.');
}

// Delete outdated tracking settings.
db_delete('variable')
 ->condition('name', db_like('googleanalytics_track_') . '%', 'LIKE')
 ->execute();

// ...


texts: How to add replicate fields when adding content?

texts:
I've got a drupal structure that I'm trying to set up for hospitality venues so it has information like opening hours, and what is going on at those times. E.g. At Joe's Burgers between 9-5 Monday-Thursday it is a restaurant, but from 9-5 Friday-Saturday it's a nightclub.

I've got fields of venue name, opening hours, and category (e.g. bar, nightclub, restaurant, etc), and therefore am able to add content for one time frame: e.g. Joe's Burgers is a restaurant from 9-5 Monday-Thursday. But I don't know how to set it up so that I can attach further details such as it's a nightclub 9-5 Friday-Saturday.

Is there a button I can add into the 'add content' section which allows me to replicate the opening hours and category fields so that I can have multiple opening hours and category combinations under one venue name?

Thanks guys!


texts:
I am working on a form.

I have this date field:

$form['date'] = [
  '#type' => 'date',
  '#title' => $this->t('Date:'),
  '#attributes' => [
    'type' => 'date',
    'placeholder' => 'dd/mm/aaaa',
    'data-drupal-date-format' => ['d/m/Y'],
  ],
  '#date_date_format' => 'd/m/Y'
];

When I set the date to August 30, 2017 I get

Firefox (Excellent!):

Chrome (Wrong!):

How can I set the 'd/m/Y' format in Chrome?


texts: D7 - How to get mlid value from path of menu item

texts: Quick question. How to get mlid value from path of menu item. There is a function called menu_link_load() but it requires an mlid value, but I need something exacly the same function using path.


texts:
I'm trying to move a Drupal site to a sub-directory of the same domain. I'm very experienced with WordPress but not experienced with Drupal sites. How would I move a website from http://example.com to http://example.com/old-website/ ?

I can't figure out what would cahnge so that I can migrate the site.

Any and all help is appreciated!

Thanks!

Austin


texts:
How do I validate a webform token in the WYSIWYG using PHP Filter format?

I have enabled PHP Filter and tried a simple conditional if statement but return an error.

Eg: if ([submission:values:keyname] == 'Test') print 'hi';

Parse error: syntax error, unexpected ':', expecting ']' in
/modules/php/php.module(80) : eval()'d code on line 2

But if I print [submission:values:keyname] it will return Test

Edit
I ended up using below code which solve my problem.

$sid = 2;
$submission = webform_get_submissions(array('sid' => $sid));
$nid = $submission[$sid]->nid;

$submission = webform_get_submission($nid, $sid);
$data = $submission->data;
$node = node_load($sid);
$components = $node->webform['components'];
$labels = array();
foreach ($components as $key => $component) {
  $labels[$key] = $component['form_key'];
}
$fields = array();
foreach ($data as $key => $values) {
  $fields[$labels[$key]] = $values[0];
}
foreach ($fields as $key => $value) {
  print $key .':'.$value;
}


texts: Taxonomy terms as arguments to an entity-reference view

texts:
I have a two content types that are classified by terms of a certain vocabulary.

The first content references another by an entity reference field (auto-complete).

What I need is as following:

When I'm creating the first content type, I choose a taxonomy term from the term reference to classify the content.

Then the entity reference field only show the nodes that are classified by the selected term (the entity reference is being filtered by a view to show the nodes of the second content type).

Does anyone has a working solution?


texts: How do I get an argument of a path with Rules URL Argument?

texts:
I am trying to get the first argument of a path in rules. That argument would be needed to fetch an Entity. I have no idea how to "tell" Rules URL Argument "get the first argument". Then I tried to get that part of the URL with regex...but I failed retrieveing just that part (it only checks whether it is "there").

I am not a coder....no idea of php...

Note: I tried for example to set the Argument path Name: site:current-page:path:1 - which is obviously not working.


texts: Is it possible to turn off Ajax load for Commerce Coupon Module?

texts:
I am getting a bunch of issues with the Commerce Coupon module 7.x-2.0-rc3. Mainly there are inconsistencies with the forms updating and also intermittent timeouts. I'm assuming it's an Ajax load issue.

Is there a way to turn off the Ajax load when a coupon is applied, and just get a regular page load?


texts: How to add cursor to text field on page load?

texts:
I'm working on an attendance site in Drupal 7 and I use a reference entity field to accept scanned ID badges. Once the ID number is saved in the field the page reloads.

I'd like to have a cursor appear in the field after the page is reloaded. I know this can be done with java script but I haven't been able to get it to work. I added scripts[] = scripts.js in the .info of the theme and created a .js file with the same name in my theme directory.

(function setFocus() {
document.getElementById("field_student").focus();

}

function select() {
    document.getElementById("field_student").select();

}

I'm not very adept at javascript and I'd appreciate it if someone could point me in the right direction.


texts: access field data in template.php and create variable for header image in page.tpl.php

texts:
I am trying to allow the user to set a custom image to display in the header on node pages that have a header_image field and to display a default header image on all other pages (including system and module generated pages).

I thought I could do this by creating a "Header Image" view and using a contextual filter to get the header_image field on the displayed node. This works okay when displaying a node that has the header_image field but not on a page that doesn't have that field. Because this view is a block the contextual filter uses the default value of "Content ID from URL" and I can't use a fixed default value.

I am guessing I have to use the preprocess_page function and field_has_data or perhaps the Entity API Module to check if the node has data in the header_image field. If there is no header_image field or it has no value I would like to use the default image for that field. Is there anyway to specify using the default image that was set by the user? other wise I would use the default image at file_stream_wrapper_get_instance_by_uri('public://')->getDirectoryPath().'/default_images/default_header.jpg'

There must be a common solution to this problem.. Actually I just had a thought.. what if there are multiple nodes on a page? Any suggestions what I should do to accomplish this?


texts: Specific permissions for rules components

texts:
I created two rules components but i can't find any module to set specific permissions for roles.

I want to let some role's users to allow run the first component but not the second one.
thanks.


texts: Add CSS class to entity reference (taxonomy type) rendered as a field in a node

texts:
This is my first question on the forum. I am currently developing a site (Drupal 8.8.1). I am developing it in a sub directory on the server and not using Drush, the server belongs to a large academic institution and they do not give me access to set up a localhost. I have a good understanding of HTML and CSS, but only the very basics of PHP.

I have a very specific theming issue I need some help with. I have a taxonomy vocabulary (a list of authors) which is displayed using entity reference (label format - link to ref entity) as a field which appears on certain nodes and views. This renders the author's name as a link that links to all other instances of that same author. This is fine, but I need to make some of the terms of this vocabulary not appear or function as a link.

The rendered HTML for the specific field I am interested in looks like this:

AUTHOR'S NAME

What I need is to do is to be able to remove the href from the anchor tag on specific taxonomy terms and add something like class="{{ name }}", or somehow get the taxonomy term ID to determine its CSS class attribute. I have tried to do this by overriding the taxonomy-term.html.twig and the field.html.twig (renaming it to specifically target my field: field--node--field-researchers--publications.html.twig). I put these two files in my MYTHEME/templates directory and disabled Views Taxonomy Term view, but I cannot make the class tag appear.

I'm not even sure if this is the best way to get the effect I want, but I can't think of another way at the moment. Any help would be greatly appreciated.


texts:
I am using one shared template - page.tpl.php for basic pages such as about us, contact us,etc. However, there are rental properties that share a different template, so i have created Content type - property page, and i would like to share a separate template for all pages of content type - property page. How to do it?

I tried to add path 'rentals/property1-3' and use page--rentals.tpl.php but it doesn't work

Any help appreciated.

Thanks


texts: Content profile fields not showing up on user registration page

texts:
I have created content profile fields that I would like to appear on the user registration form. I am using drupal_render to render these fields on a custom user registration page but they are not appearing. However the other non content profile fields are appearing. Any ideas as to what I could possibly be doing wrong?

I am using Drupal 6.26

Thanks.


texts: Why are IDs showing in URLs when clean URLs are enabled?

texts:
I've enabled clean URLs on my site, and currently, URLs are of the form:

  /node/123

How can I force them to to use human-readable URLs? Something like:

  /node/title-of-node


texts: Theme suggestions for blocks in a region which has a dash in the name

texts:
I have a Region in the theme called header-top. As you may notice this region has a dash in the name instead of an underscore.

This theme is a sub-theme of a master theme called Framework. I wanted to apply a certain template file to blocks in that region, so according to Drupal 7 Theme Hook Suggestions page I've created a template file called block--header-top.tpl.php and cleared the cache. After re-loading the page a few times, I inspect the HTML to see if this particular template file is being applied, but all evidence suggests that it's still using block.tpl.php. I've tried using template_preprocess_block and dpm-ing out the $variables and in there I see an array theme_hook_suggestions which has the following values: array(block__header-top, block__block, block__block__21). I've checked the existing template files and there's no template file named block--block.tpl.php or block--block--21.tpl.php. I've even tried to swap the dash with an underscore to be block--header_top.tpl.php but still no luck.

Finally I've switched the region name to become header_top and the renamed template block--header_top.tpl.php suddenly starts to take effect.

I'm wondering is there a certain naming convention for regions with dashes in the name? If so what would be the ways to try and find out what exactly the template name for this region should be? I'd like to not resort to renaming the region, as that may have a knock-on effect on modules and other template files which I may miss and mess up the production website.


texts: Using a view result as allowed_options in a text(list) field

texts:
I have a set of values that are created in a different node, and I would like to use them as the allowed values for a field in another node. So, I have a view that collect the values and I have a hook_allowed_values function to create the allowed_values list. My function is:

function hnbuilder_fheq_allowed_values(FieldStorageConfig $definition, ContentEntityInterface $entity = NULL, $cacheable){
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
        $nid = $node->id();
    }
    $view_id = 'default';
    $args = $nid;
    $result = views_get_view_result('outcomes',$view_id,$args);
    return $result;
}

My problem is that my views_get_view_result is not returning anything. I get the correct $nid, and pass this to the views...result. The view, on its own, works fine. But if kint($result), I get nothing.

I've updated the config for the field, to make it call the hook_allowed_values function.

What am I doing wrong?


texts: Cache + random + hook_form_user_register_form_alter

texts:
for a captcha purpose, I'm trying to set a random number in the hook_form_user_register_form_alter

For example :

function my_module_form_user_register_form_alter(&$form, &$form_state) {
    $random_case = rand(0, 3);
    $form["random"] = array(
        "#type" => "textfield"
        , "#title" => ""
        , "#disabled" => 0
        , "#value" => $random_case
        , "#description" => null
        , "#weight" => -2
    );
}

When cache is disabled it's working as intended.

when I enable the cache the random number is always the same until I flush all caches.
I tried to flush cache programmatically, but it doesn't seem to work. What can I do ?

if I put a

die($random_case);

It's working but I think it's because drupal can't put the hook inside the cache.

Best regards.


texts: Webform conditional component element invisible

texts:
While working with the Webform module (7.x-4.x), I found something I wasn't sure about.

I made a normal text field and then a selected list. After which I added conditional statements to make other things appear after the select list. One of which was another select list.

However, the label name for the second select list completely disappeared.

On closer inspection, ( Ctrl + U ) found the label had become invisible.

Any word of this? Is this a known bug?


texts: How do I hide /sites/default/files from URLs?

texts:
I want to upload files to their normal directory under /sites/default/files/. So let's assume I have example.pdf uploaded to sites/sites/default/files/manuals/example.pdf.

I want the links to files look like http://example.com/manuals/example.pdf. I think it's simpler and looks more professional.

How can I achieve it with Drupal?


texts: How to Redirect search form to search api views

texts:
I'm struggling to redirect the core search form /search/node/* to the search api views /s* .

I took a look at but nothing happens ...

http://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_box_form_submit/7

also tried
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form') {
    $form['#action'] = 'search';
    $form['#submit'][] = 'MYMODULE_search_form_submit';
  }
  else if ($form_id == 'search_box_form' || $form_id == 'search_theme_form') {
    $form['#submit'][] = 'MYMODULE_search_form_submit';
  }
}

function MYMODULE_search_form_submit(&$form, &$form_state) {
  $default = search_get_default_module_info();
  $form_state['redirect'] = str_replace("$default[module]/", '', $form_state['redirect']);
}

Tried different modules ... but they don't pass the results..
Also tried to add the search form from views on the front page and managed to get it wrong .. all sorts of errors.

Cheers


texts: Why does trying to POST a node from Android result in "HTTP/1.1 415 Unsupported Media Type"?

texts:
I used the following code to post some data to my site. I tested the site with Postman using the same data and it works properly, but when running the following code on Android Studio, response.getStatusLine() returns HTTP/1.1 415 Unsupported Media Type.

       HttpClient httpClient = new DefaultHttpClient();
       HttpPost httpPost = new HttpPost("http://www.example.com/entity/node");
       HttpResponse response = null;
       String responseBody = "";

       try{
           JSONObject json = new JSONObject();
           JSONObject c0 = new JSONObject();
           JSONObject c00 = new JSONObject();
           JSONObject c1 = new JSONObject();
           JSONObject c2 = new JSONObject();

           json.put("_links",c0);
           json.put("title",c1);
           json.put("type",c2);

           c0.put("type",c00);
           c00.put("href","http://www.example.com/rest/type/node/article");
           c1.put("value", "test string");
           c2.put("target_id", "article");

           String base64EncodedCredentials = "Basic " + Base64.encodeToString(
                   ("user"+ ":" + "pass").getBytes(),
                   Base64.NO_WRAP);

           StringEntity se = new StringEntity(json.toString());

           se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

           httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");
           httpPost.setHeader("Authorization", base64EncodedCredentials);

           httpPost.setEntity(se);

           // Execute HTTP Post Request
           response = httpClient.execute(httpPost);

           String jsonResponse = EntityUtils.toString(response.getEntity());
           JSONObject jsonObj = new JSONObject(jsonResponse);

           if (response.getStatusLine().getStatusCode() == 200) {
               Log.v("response ok", "ok response :/");
           } else {
               Log.v("response not ok", "Something went wrong :/");
           }
       catch (Exception e){
           Log.v("Error posting:",e.getMessage());
       }

I tested each of these lines separately and together, but none of them work.

    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));

           httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");

Why does it return HTTP/1.1 415 Unsupported Media Type?


texts: D7: Import localized menu programatically

texts:
I'm constructing a site that has 6 localized versions (English, German, Russian etc.). So the site is supposed to have a localized navigation menu with a common structure across the languages.

I've decided that importing menu items though several Drupal API calls would be the quickest way to create the menu structure I need. So I've learned how to save menu links with menu_link_save() function and they even get their language field set correctly... but those imported items in different languages mix with each other and get displayed all togeher :-(

When I open and save some imported menu item through Drupal administrative interface it starts behaving properly and gets displayed only when the site is in it's language. Also the 'options' database field for this item becomes populated with some additional data compared to other imported items.

So my question is: what i18n API or some other function should i call to save menu items with all needed options? Maybe there is a better way to painlessly import menus?

Thanks in advance!


texts: How to prevent running "updb" twice for upgrading Media

texts:
I'm upgrading my custom media modules to use the "core media" in Drupal 8.4.8

I have to run the command "drush [sitename] updb"  twice in order to recognise my custom media modules code has been upgraded.

The first run - it show me an error, I need to upgrade my custom media modules to be compatible with the core media.  However, if I run the same command again, it then show me a list of the updates is going to run.

My question, Why I have to run it twice to get it recognise my custom media modules has been updated.  This will also caused a problem during deployment, because the deployment only run this command once.


texts: How to completely hide a table header in views?

texts:
In views when you use the table layout and don't select labels it still creates an empty header, for example:

I can hide it with CSS. What would I have to do to access the render array and unset the element before the HTML is generated?

Is there any other way to remove the  tag?


texts: How do I make variables available for all blocks in a page?

texts:
In my website I have an inc file containing some values that are needed on all blocks of a page. For reasons related to the performances, I would like not to use the php "require" function in each block. Is there a way to load this file at page level and make the values available in all blocks?

Do I have to do that in the template_preprocess function?


texts: What is the right way to count filled multi value field values in drupal?

texts:
I've a term reference multi value field.  What is the right way to count filled values which is also portable to D8, D9 etc.

The dsm output shows like this:


texts:
With Drupal 7 we had the Field Rename module, but this has not yet been ported to Drupal.

So what SQL magic is needed to rename a field in Drupal 8?


texts: How can I install Drush without Composer?

texts:
I've been trying to install Drush for a while but have failed. I have no experience in command line applications.

I've seen quite a few tutorials:

https://www.drupal.org/node/594744
https://www.drupal.org/node/2405811
https://drupalize.me/videos/wonderful-world-composer
https://getcomposer.org/doc/00-intro.md#installation-windows

but each one says that Composer is required. The catch, I can't seem to get Composer to work either.

Would I ever be able to install Drush, but still work around installing Composer?

Specifications:

Windows 10
Drupal 8.1.8
Cpanel 56.0.33
Php 5.59 (or higher according to this)
Composer Manager 8x-10-rc


texts: How do I set a tag via cookie and filter content on the whole site based on that tag?

texts: I have a site which has different tags for different cities. Most of the content on the site is either for all cities or a set of specific cities. I am planning to have all the content pieces taggable via taxonomy references. Within my template I want a dropdown which sets the current city. What is the easiest way to only show correct content based on this drop down througout the site?


texts: Parent node does not update when updating referenced entity child node

texts:
I have a node type called page which references a node type called slider. I am using the Drupal 8 rest module to make updates to content.

I make a PATCH request to update the slider content and it says the content had been updated. When I view the slider content I can see the updated version all good but when I view the page (which renders the reference entity) it is still showing the older revision of the slider.

When I update the page by saving it to sending a PATCH to update the page then it shows the most recent version.

Is there a way to update a entity reference field (slider in this case) and also have the parent (page) also auto update with the changes?


texts: How to open a login,registration and forget password form in a popup programmatically?

texts: I want to open a user login form in popup after click on user link same as under login form I have create new account link I also want this to popup.. I have used 2-3 modules like modal_form colorbox etc. Its not full-filling my need. Because I need to customize my login form.


texts: Rules - anonymous users redirected to user/login prevents request new password link from working

texts:
I'm using the rules module with drupal 7 in order to redirect anonymous users to the login page.

Events: Drupal is initializing
Conditions: User has role(s) - Parameter: User: [site:current-user], Roles: anonymous user
NOT Text comparison - Parameter: Text: [site:current-page:url], Matching text: user/login
Actions: Page redirect - Parameter: URL: user/login

My problem is I need the "request new password" to work. How do I tell Rules to ignore clicks to user/password?

This is the current setup for the Actions but it doesnt work.

When a user gets to the login page I want them to be able to click Request New Password and not be redirected back to user/login.


texts: Theming a menu - removing a whitespace between the last  and

texts:
I want to alter the HTML of the main menu. I have a manu set up with text-align: justify.
Now in Chrome, the whitespace between the last li and ul is rendered as 4px, making the last item not aligned to the right margin. See this stackexchange post. I want to remove the whitespace or replace it with and html comment.
I am a bit lost ;-). What should I be overriding? theme_menu_tree?
I am using the Omega 3.


texts: How to remove the top, bottom, left... region when theming a node in Drupal 6

texts: After some revise on the template.php, I can theme a node with specific content type. However, could I remove the default region such as header, footer to make it likes a blank page?


texts: How to get the list of nodes edited by an specific user?

texts:
I need to be able to see all the nodes that have been edited by an user and be able to download that info, I've been searching for a module but I can't find one.

On the log messages report I can see that info but I can't download it and also it only shows the data for the last month.


texts: "Convert Media tags to markup" in CKEditor is not working

texts:
I have a strange problem when trying to add an image by 'Add media' in CKEditor 4.3.1. I know that this topic is very frequent. In most cases the resolution is to check "Convert Media tags to markup" in Text formats configuration... but I have checked this and it's still not working.

I can add an image to media library, after this I can choose an image format, but finally when I try to add the image it's not showing neither in the editor window nor on front.

Seems that no code is adding or the media tags are not converted to markup.

Do you have any ideas?


texts: Why is cache_discovery not rebuilt on cache-rebuild?

texts:
In my local dev environment drush cr does not rebuild the cache_discovery table.  I have to manually truncate it.  Is it because expire is set to -1 on all rows?  If so, did I mess something up in setting up this site?

I think I could add $settings['cache']['bins']['discovery'] = 'cache.backend.null'; in my local settings file, but then I'd have to truncate it in production when making changes like the one that brought this up.  This doesn't seem right.

Maybe I'm just missing a setting somewhere, but drush cr, rebuild.php, and restarting apache all leave cache_discovery exactly as it was.


texts: How do I use rules to iterate over the subscribed users of a organic group to send email notifications?

texts: Using the great tutorial at http://webwash.net/tutorials/log-site-activity-message-and-rules I have been able to set up my Site Activity Log. I now want to extend it to be able to use message_subscribe and message_notify to send users, that are following the organic group, an email with the info. In rules I have been able to add an action Send Message with Message notify. However, I can't seem to set "The recipient of the email" to users that flagged (following) the group. Any insight into how to pull this into the rule would be much appreciated.


texts: Is there a way to bulk import images from server and auto create nodes for each image? this is for Drupal 7


texts: How can I extract a specific field from a set of nodes?

texts:
I am using Drupal 7.

I have a custom content type with multiple fields. For example, one field contains a thumbnail image. Another is a text field.

There are 36 nodes that use this custom content type. In database terms, I have 36 records.

How do I have Drupal extract a specific field from each of the 36 'records' and display them on a single page?

For example, in PHP I could write an SQL query such as "select fieldname from table" and display using while() { print $row['fieldname']; }.

How do I achieve this using Drupal 7?


texts: Exposed date filter doesn't work with 'greater than' or 'less than' and 'is equal to'

texts:
I'm working on a Drupal 8 site where I use a exposed filter to filter on date. I created a simple version of what I want on simplytest.me.
In this example I created a article with a start and end date.
Start date is 28-02-2018 01:00:00
End date is 28-02-2018 10:00:00

I also created a view with two exposed filters to filter on date range.
Exposed filter 1: >= Startdate
Exposed filter 2: <= Enddate

When I add 28-02-2018 in both filters the result is null. When I look in the query, I see it says 2018-02-27 instead of 2018-02-28
What is going wrong? It looks like it doesn't see the is equal to part of my filter.

Is this normal? How do I make this filter work as I expect?
I tried to fix it with https://www.drupal.org/project/drupal/issues/2627512#comment-12382345, but this only adds an hour, not a full day.


texts: Adding a dependencies in theme info file

texts: Can I use dependencies[] = module name in the theme.info file? I want to create a drupal theme where I using some dependencies module, if I able to mention the dependencies in theme info it will easy to install the theme.


texts:
I have a node-type with an image field. while uploading a file I would like to put it in a node-specific directory which is named after the node title.
while using tokens, there is no node->title, while I am creating the node, so the current-page:title is the node->type I am trying to add.
so this works only when adding files to an existing node.

my solution-idea:

should I restrict adding files before the node is already created? the node should be created unpublished.

are there other solutions / a shorter way e.g. a two-step-edit-form?


texts: What is the best way to add a confirmation tooltip to the remove button of a managed_file field?

texts:
Another Update

I'm trying to implement the solution found here: Intercept click event on a button, ask for confirmation, then proceed, but the remove button still submits normally. I know my JS is targeting the correct element, because I can change other attributes on it like the background color.

Here's my form:

function form_experiments_01() {
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'form_experiments') . '/js/form_experiments.js',
  );

  $form['managed_files'] = array(
    '#type' => 'fieldset',
    '#title' => t('Managed Files'),
  );

  $num_docs = 3;
  for ($i = 1; $i <= $num_docs; $i++) {
    $form['managed_files'][$i] = array(
      '#type' => 'managed_file',
      '#title' => 'Managed File ' . $i,
    );
  }

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

  return $form;
}

Here's my javascript:

(function ($) {
  Drupal.behaviors.managedFileAutoUpload = {
    attach: function(context, settings) {
      $('.form-item input.form-submit[value=Upload]', context).hide();
      $('.form-item input.form-file', context).change(function() {
        $parent = $(this).closest('.form-item');

        //setTimeout to allow for validation
        //would prefer an event, but there isn't one
        setTimeout(function() {
          if(!$('.error', $parent).length) {
            $('input.form-submit[value=Upload]', $parent).mousedown();
          }
        }, 100);
      });
    }
  };

  Drupal.behaviors.managedFileConfirmRemove = {
    attach: function(context, settings) {
      var myButton = $('.form-item input.form-submit[value=Remove]', context);

      if (myButton.length > 0) {
        var myClick = null;

        //get a list of jQuery handlers bound to the click event
        var jQueryHandlers = myButton.data('events').click;

        console.log(jQueryHandlers);

        //grab the first jquery function bound to this event
        $.each(jQueryHandlers,function(i,f) {
          myClick = f.handler;
          return false;
        });

        //unbind the original
        myButton.unbind('click');

        //bind the modified one
        myButton.click(function(){
          if(window.confirm("Are You Sure?")){
            myClick();
          } else {
            return false;
          }
        });
      }
    }
  }
})(jQuery);

Update

After some more research I found this question. This is what I was trying to ask but didn't know how to word.

Intercept click event on a button, ask for confirmation, then proceed

I'll implement this solution and post a resolution once I've got it working.

Description

I would like to add a confirmation tooltip when the "remove" button is clicked on my managed_file field.

I would like to do something similar to this:

What is the best way to do that?

Possible Solution?

So far, I'm thinking I could probably use javascript to hide the remove button and instead display my own button. Then when my button is clicked, I can trigger a popup that contains a second custom button to cancel and the remove button that I originally hid.

I'm worried that this solution is a bit messy. Is there a more elegant way to do this? Can I get a similar behavior without hiding the original remove button?

Similar Questions

I'm not sure if these apply to my use-case since I'm working with a managed_file field. So far, I've been unable to implement similar solutions without the default behavior of the remove button interfering.

Confirm delete via AJAX
enter link description here

Resources

Bootstrap-Confirmation.js
Drupal Form API Reference - managed_file


texts: Commerce Order id as seletion list in view filter and limit to 10

texts:
I am trying to make Order id as selection list exposed filter but couldn't make it possible.
I modified default order view by making clone, added block to view.This view block will be presented to the authenticated user where he can view his/her last 10 orders.

In views sort criteria order date is added which is in descending so that only most recent orders are fetched
Pager setting  - Use pager: Display a specified number of items | 10 items

Order's details has to be shown when user selects any order no from select list.
Is it possible to make selection list of Order id?Is there any module for that?


texts: Acquia Desktop & MAMP: No Drupal site found, only 'drush' cache was cleared

texts:
Usually I use MAMP for my local development server which already has all of my shortcuts and stuff configured the way I like it.

A client was on Acquia Cloud and to prevent conflicts with other developers we are all using the Acquia Dev Desktop for local. Acquia Dev Desktop comes with Drush within its own package.

When running my drush cc all I was getting the following error:
No Drupal site found, only 'drush' cache was cleared

After running drush status I noticed that Drush was trying to use my MAMP version of drush and thus resulting in no site found.


texts: Empty cart functionality with a link, (no form) in Ubercart

texts:
I'm trying to make a link (not a form submit) to empty the cart; my link would be /cart/empty.

I can't find where to make a case or something for the URL to work.
I know I have to use uc_cart_empty(uc_cart_get_id()) to empty the cart.


texts: system_retrieve_file() not returning fid

texts:
when I'm calling system_retrieve_file like:

$thumbnail = system_retrieve_file($thumbnail_url, NULL, TRUE, FileSystemInterface::EXISTS_REPLACE);

It downloads the image into the file system, but when I try to print the  $thumbnail object, it won't give any value for the file ID.

When I run the same code again, with the same thumbnail URL, it gives me the file ID.

Why doesn't the code return the file ID the first time is run?


texts:
In Drupal 8, I have a Flag entity with a date field attached.
My code looks like this:
function MYMODULE_flagging_presave(FlaggingInterface $flagging) {
    if ($score == 0 || $score == 1) {
      $flagging->field_date_review = date("Y-m-d", strtotime('today'));
    }
    else {
      $date = date("Y-m-d", strtotime("+$interval days"));
      $flagging->field_date_review = $date;
    }

I checked and the dates get stored in the database like 2020-07-02.
I have a custom view that shows these flaggings, and I added a filter for nodes with a date field value of less than +1 days; this behaves as expected, so the Views module seems to understand the dates as I stored them.
But, when I try to add the date field, I get an empty display in Views.
Further debugging
When I render the flagging entity, the date field doesn't show a value, either.
Other fields set in ``hook_flagging_presave()` are displayed correctly; it's only the date field that doesn't have a value.
Configuration
On the flagging entity's Manage display screen, I have set my date field to use the Plain format with no timezone offset. I also tried the Default format and several others, but nothing let me display the value.
There are no errors in the recent log messages.
To sum up: the date field has data in the database, which Views can see and use for filters.  But, this date field cannot be displayed in Views or on the rendered flagging entity.
What do I need to do to get the date to be displayed?


texts: How to prevent closing ctools modal window with ESC?

texts:
I am using ctools modal window to edit some records with Form API.
How can I prevent closing window with ESC key and the default close button?


texts: Drupal add fieldset inside form and wrap all form elements under that fieldset

texts:
I want to add fieldset tag inside form tag. Also i want to wrap all the form element under this fieldset. I'm using the following function to change the form design and html.

MY CODE:

function change_password_form($form, &$form_state) {
  if (user_is_anonymous()) {
    return $form; // Or drupal_access_denied()?
  }
  $form['#account'] = $GLOBALS['user'];
  $form['fieldset']['current_pass'] = array(
    '#type' => 'password',
    '#title' => t('Current password'),
    '#size' => 25,
    '#required' => TRUE,
  );
  return $form;
}

CURRENT OUTPUT :

<form action="/projects/drupal/hpedu/change-password" method="post" id="change-password-form" accept-charset="UTF-8">

  Current password *
 <input type="password" id="edit-current-pass" name="current_pass" size="25" maxlength="128" class="form-text required">

<input type="submit" id="edit-submit" name="op" value="Submit" class="form-submit">
<input type="hidden" name="form_build_id" value="form-pGcx3HehTZlOkicX1gaBrr5eBjv8iT6iccQvCN8uXTU">
<input type="hidden" name="form_token" value="1qygden7YqhLlXvjiC8-ypYDXhOKwW_brUB4BdXlKNU">
<input type="hidden" name="form_id" value="change_password_form">

</form>

EXPECTED OUTPUT :

<form action="/projects/drupal/hpedu/change-password" method="post" id="change-password-form" accept-charset="UTF-8">
<fieldset class="myclass">

  Current password *
 <input type="password" id="edit-current-pass" name="current_pass" size="25" maxlength="128" class="form-text required">

<input type="submit" id="edit-submit" name="op" value="Submit" class="form-submit">
<input type="hidden" name="form_build_id" value="form-pGcx3HehTZlOkicX1gaBrr5eBjv8iT6iccQvCN8uXTU">
<input type="hidden" name="form_token" value="1qygden7YqhLlXvjiC8-ypYDXhOKwW_brUB4BdXlKNU">
<input type="hidden" name="form_id" value="change_password_form">

</fieldset>
</form>

Any help would be greatly appreciated.


texts: Spam registrations even after adding domain to Mollom blacklist

texts:
I have a problem with spambots from itregi.com and drupaler.org that registers accounts on my clients Drupal site. I have Spamicide and Mollom installed and I have also added the domains to Molloms blacklist in the following format:
Author e-mail   contains    itregi.com

But they still get accounts with these domains as email.
I don't know what to do more or if I am using the blacklist wrong? Any suggestions?


texts: Blocks: Old vs. "Custom" and Config vs. Fields

texts:
I have quite a bit to ask in this question, so I apologize in advance. I believe these questions are all related, and I'm trying to grasp some thoughts on the new block system in Drupal 8.

Background

I am troubleshooting a custom block implemented by a vendor. This block is not listed in the Custom block library, but I can add it to the page with the Place Block link on the Block layout page (note: this makes me think it's an "old-style" block, as in D7 type block). When I place a new block, I am presented with a "Configure block" screen, which I believe shows and stores the values of these fields in config. The custom class extends BlockBase, so the form I'm seeing is built/shown/processed with blockForm() and blockSubmit() in the code.

The problem I am having is that files/images added via these "config" fields (aka a form file upload field, or a wysiwyg editor's IMG button) upload "temporary" files to the file system, which are then later deleted as orphans by a cron run a few hours later. I realize I can turn off that cron job, but I am looking for a BETTER solution. When I go to the files page (/admin/content/files), I want to see that my uploads are "used in" at least one place, and have that place show correctly as a link to the block. My belief, is that if this block were built as a custom block type, using fields, that Drupal would by default take care of the association of these images, which really are content.

Questions

So this brings me to some questions... Am I on the right path here? Should I be using fieldable, custom blocks for this implementation? If the image is a field, and the body is a field, and saved appropriately in the database, then the files page will be able to see this content correctly. This is do-able, correct?

So this brings me to my next question, when should I be using blocks/configuration and when should I be using blocks/fields? This particular example screams "content" at me, and in that case, I think the argument is for fields. Does that sound right? I can think of another example off the top of my head that I'm a little more fuzzy on. We offer a custom block for "Polls" on our website where, when creating a new poll, you choose a reference to a poll, and can optionally set (override) the Title shown in the block. That's 2 settings that a site admin should be able to change. Are these still content, or are they config? To me, it seems like the "poll reference" could go either way... I assume most custom blocks have some combination of "content/fields" AND "config", right? For example, all the "Visibility settings" for a block get saved as config, right?

Any help understanding all of this is much appreciated! Thank you!


texts: How can I determine in the body of a hook implementation what hook it is implementing?

texts:
I have a functional understanding of what the hook system is and how to use it in Drupal, but would like to deepen my knowledge. Normally when writing a hook, I know exactly what hook I'm using, because I've looked up what hooks were available, chosen one that suits my need, and implemented it. Sometimes though, I have a situation where I look at the THEME HOOK provided by the debugging output in the HTML, and I write a hook for that, and maybe add a couple of specifiers. For example, if I see this debugging output:

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'page' -->
<!-- FILE NAME SUGGESTIONS:
   x page--user--edit.html.twig
   * page--user--555.html.twig
   * page--user--%.html.twig
   * page--user.html.twig
   * page.html.twig
-->

I might implement a hook for page__user__edit. If I am in my theme called my_theme, I know I can go into my theme file my_theme.theme and implement the hook there, and that if I do I should begin the hook with my_theme_preprocess. So all together my hook should be my_theme_preprocess_page__user__edit, and I test it, and it works, and that part is all good.

Where my confusion comes in is when I go to specify parameters or document the function. What parameters does the function take? What hook does it implement? I am usually able to guess on the parameters, since usually it is (&$variables), but sometimes they are different. Ideally I would like to look up exactly what parameters the function takes based on the documentation for the hook, rather than trying to guess, but looking up the documentation for the hook can require some guesswork itself if you don't know what hook you are implementing. Some hooks are hook_preprocess_whatever, others are template_preprocess_whatever. Other times, like for a block, I wrote the hook my_theme_preprocess_block but it turns out this is not implementing hook_preprocess_block, it is implementing hook_preprocess_HOOK (or so I believe). So, once I have written a hook implementation (i.e. my_theme_preprocess_block or my_theme_preprocess_page__user__edit), how can I definitively know what hook I have just implemented?

Currently, I just Google a few different plausible-seeming hooks that I might be implementing, and if one of my guesses is correct or I get close enough that Google gives me a suggestion, I'm all set. In the case of the hook above, I'm able to find documentation for a template_preprocess_page function, and no such hook_preprocess_page function. Sometimes the results of this Googling process are less clear though, and leave me uncertain of what hook I have just implemented (like for the block - hook_preprocess_HOOK is very generic, how can I be sure I'm not implementing something more specific that I just missed in my Googling?). So if there does exist a way to definitively tell what hook you are implementing using a debugging tool or something, I would very much like to know about it.

I've tried using kint($variables) inside of my hook implementation (e.x.

function my_theme_preprocess_page__user__edit(&$variables) {
  kint($variables);
}

) but the closest thing I could find in there was theme_hook_original, which for the above gives 'page', so doesn't resolve these ambiguities about what hook I'm implementing.

Or, if there doesn't exist a way to tell what hook you are implementing with a debugging tool, is there a better way to figure out what hook I'm using other than what I'm doing? I'm open to suggestions on any level, including ways I should revise my workflow, something I should know about the difference between template_preprocess_whatever and hook_preprocess_whatever functions that if I knew that thing I wouldn't be confused, or whatever else. Thanks!


texts:
In Drupal 8, what is the correct way of returning access denied to a user (outside of access requirement on a controller)?

I'd say it is to throw an AccessDeniedHttpException most of the time, but I have seen modules set an event response to 403, or do a redirect response to system.403.


texts: How to add rel=author when you have "multiple authors" in one site?

texts:
I would like to use Google rel=author meta tag, but I do have several authors writing in one site. I have a Drupal 7 site. Should I add a different authorship for each author?
How should I manage in that case?

I was planning to use meta tags module, (as explained here) but the only way it seems to modify all urls in order to affect different url with different meta tags.
ie: /authorname/title that way, with different urls I could create different meta tags.

Could that be a normal procedure? Or there´s another way to add the author´s context?
Or maybe you just should use one single author and avoid multiplying authorship altogether?

Ps. I don´t think this is a duplicated post, because this one refers about multiple authors, instead of just asking how to implement rel=author in D7.


texts: "Access denied" whenever trying to edit IMCE User-1 profile

texts:
After reinstalling IMCE, I am trying to see the User-1 profile by accessing the "admin/config/media/imce/profile/edit/1" URL. But it shows following error "Access denied. You are not authorized to access this page."

I have verified (URL admin/people/permissions) that administrator has privileges for IMCE module. Also rebuilding permissions is not helping here.


texts:
Say I am extending The blockBase class to create a custom block, and I am implementing the blockBuild method to create some markup for my block. Something like this:

 class YourModuleBlock extends BlockBase {

   /**
     * Implements \Drupal\block\BlockBase::blockBuild().
     */
     public function build() {
      return array(
        '#markup' => 'This is a block!',
      );
     }
   }

If I wanted to provide a link in this markup, in D7 I would have used the l function, but this is no longer available (see here). So, I need to make available the new D8 method for generating links. I could just use an <a> tag, but this was never best practice in D7.

So, what is the right method to use for creating links and how do I make it available to my function?


texts: Including a file on every page in a module

texts:
I have a module that provides about two dozen pages (in a site with 1000s of pages). I have a file that contains a number of large functions. I want to include this file on every page used by my module. My options appear to be:

Call module_load_include in every page callback - seems a slight pain
Add the file option to every item in hook_menu (which would be fine as long as I don't want the page callbacks to go in a separate files from my .module file)
Wrap all the functions in a class, include the file using files[] in my .info file and then call the functions like myclass::myfunction() [which sorta seems a slight misuse of the class system as most functions are returning arrays of data unconnected to each other]
Load the file in hook_init, which means it would be loaded for every page in my site, not just the dozen specialist pages

It looks like 3 may be the best bet, but I'm just wondering if I'm missing something that allows me to include the file in one place just for my module pages without lots of duplicate calls to module_load_include and without using classes.


texts:
I've learned how to create groups via Organic Groups, and I learned how to use the Calendar to create a site wide calendar.

I guess what I need help with now is how to integrate the two. I can't seem to figure it out. Any tips?


texts: Access restriction modules block nodes, but not teasers?

texts:
Please forgive if this is bad form - this is my first post here, and I realise it's very similar to this existing question, although slightly different.

I'd like my site to have a bunch of public info, some members-only info, and some info only for super-users. All of the content-access modules I've tried seem to work when viewing the actual node, but in the taxonomy pages the teasers for these pages are still visible (thus leaking information). In short, you can see which pages you're not allowed to read in full, and that's a problem.

How can I make sure that users only see content --in any way-- that they are permitted to see?

I've implemented my access model by making three distinct roles (well, anonymous, authenticated, and "super user"), and three distinct content types for each user role and then assigning access based on content type, although for a very few nodes I do need to override this with node-level access control (for making a super-user page available in view-only mode to regular members). I'm not interested in per-user access control as such, per-role (with per-node override) is sufficient.

My site runs Drupal v7.2 (but I'm upgrading to 7.4 as I post this), and I've tried the modules named Node Privacy By Role and Content Access. Both of these work very nicely, except for the issue mentioned above.


texts:
My issue here is that I would like to execute Query 1, return an array of values from Query 1, and then exclude those values from Query 2.  The reason for this is I will be performing an insert function in between (and want to leave my insert function untouched).

Query 1:

$notquery = db_select('uc_packages', 'p')
           ->fields('p', array('package_id'))
           ->condition('p.order_id', $order_id)
           ->condition('p.sid', NULL)
           ->execute()
           ->fetchAll();

foreach($notquery as $foo) {
  $notarr->pid = $foo;
}

Insert function:

uc_shipping_package_save($package);
...

Query 2:

$query = db_select('uc_packages', 'p')
             ->fields('p', array('package_id'))
             ->condition('p.order_id', $order_id)
             ->condition('p.sid', NULL)
             ->condition('p.order_id', $notarr, 'NOT IN')
             ->execute();

This returns an error:

  Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2139 of /var/www/seven/includes/database/database.inc).

It is understandable. My question is how do I pass my array through that query.


texts: Translating "Content: Link" in a Drupal 7 View

texts:
I am working on my first Drupal 7 site that has internationalization. My site is in both English and Spanish. Generally I am pretty happy with the way it's going so far. The basis of my translation is using the Entity Translation Module and it works great, Views are translated seamlessly.

However, I have run into a snag, When I create a View and add "Content: Link" as a field, essentially a "read more..." link to the node, I am finding no way to translate the "Read more..." text that I enter into the "Text to display" textbox. My guess is because it's not actual content in the node that's been translated. I've looked around here, on drupal.org and my google-foo is failing me too. Just looking for some suggestions on how to do this.


texts: How to display the user picture on the search page?

texts:
I want to show the user picture on the search page. Currently only its show the user email or name, but I want to show the user profile picture.

How can I do that?

Note: the search page is about the user type, so when I search some users their picture should be displayed on the search result page.


texts: Template name suggestion for multivalue image field in paragraph module?

texts:
How can I create a dedicated template name suggestion for paragraphs multi value image field?

The below HTML comments are the theme hook suggestions added by the debug function, for the paragraph multi value image field.

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'image_formatter' -->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/field/image-formatter.html.twig' -->
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'image' -->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/field/image.html.twig' -->

As you can see from the template name suggestions, there is nothing to distinguish this intended image field from others.


texts: Panel Page with Node Views, Flags and Rules Integration

texts:
I created a page where users can submit friendly games. Other users can show their interest by flagging (Flag A) these games.

The author of the game can see all prospects in another view (View 3 integrated in View 2 with Views field).

The author than can choose which prospect for a friendly game he accepts. He does this by flagging the prospects flag with an accept flag (flag B).

The accepted prospect than gets an email confirming the friendly game.

How is it possible for me to send emails to all prospects who did not get accepted?

I tried Rules (on flagging event) and Rules Link.

How do I tell Rules what friendly game node this is all about?

Hello, thank you for your ongoing help! I created a list of friendly games with relationships and contextual filters that display these users.

When I use "Load a list of entity objects from a VBO View." or "entity ids" drupal throws error messages at me.

Warning: Invalid argument supplied for foreach() in _views_bulk_operations_get_field()

Another really strange error for this rule is "Illegal choice blog in type element." The view does not display blog types... I'll try to figure this whole mess out.

Another problem in my opinion would be that in my view is a contextual filter that gets the NID of the friendly game by the view it is integrated in by "views field module". So how does the view know what users it should display if I loop it with a rule? Wouldn't it just loop through all users that flagged any friendly game who are not flagged?