texts: Cache busting for images in Drupal 7 and lightbox 2

texts:
Scenario: I have content type with a field 'images' (Widget: plupload). View created and displayed on Home page. View has Formatter: LightBox2, LightBoxType: Single Lightbox, Image-Style: thumbnail image-style for the images. Whenever user click on image, LightBox2 shows original image.

Problem: Everything working fine. But the images are getting cached in browser cache. Hence I followed https://www.drupal.org/node/2313539 Cache Busting discussion and changed theme.inc theme_image() function. Now the thumbnails have time(cache busting string) in their name but lightbox still the same.
I get the point that i have write or hook the formatter as well to make it work in views. Not sure where and what should change in LightBox module or elsewhere.

This is what HTML looks like on page

<a href="sites/default/files/images/3.jpg" rel="lightbox[field_images][
Download Original
]" title="" class="lightbox-processed">***

where  tag has src url appended with '&hash=2563415' i.e. cachebust string, but anchor-element doesn't have the same.
Any ideas how to make Lightbox2 anchor element to include cachebust string element as well.
Drupal version:7.41, LightBox2


texts:
i want to change values of only checked elements on tableselect.
How can i do that please ?

this is my tableselect :

$form['tab'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#empty' => t('empty !'),

);
return $form;

i've also a submit button that makes changes (update database) on one column of the tableselect :

 $form['published'] = array(
        '#type' => 'submit',
        '#value' => t('Publish'),
        '#states' => array(
            'invisible' => array(
            ':input[name="select_list"]' => array('value' => 'Published'),
            )
            ),
        '#submit'=> array('publish_submit'),
    );

My function to make changes (to publish elements that aren't now) :

function publish_submit($form, &$form_state){
$check = $form_state['values']['tab'];
//$check = array_filter($form_state['values']['tab']);

$sql = db_update('field_data_field_books');
$sql->fields(array('field_books_value'=> 'Published'));
$sql->condition('entity_id',$check); //update only books i checked on the tableselect
$query = $sql->execute();
   }

this is what dsm($check) returns (when i check one or more elements on the tableselect )

this is dsm($rows) (6 elements are ok):

This is how i created the $rows :

$rows = array();

foreach ($result as $res){

    $rows [] = array(

            'book_title' => l($res-> field_title_value, 'node/'.$res->entity_id),
            'book_state' => $res-> field_state_value,
            'book_editor' => $res-> field_editor_value,
            'book_categories' => $res-> name,
            'edit_books'=>l(t('Details'), 'node/'.$res->entity_id.'/edit'),
          );

}

$form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#multiple' => TRUE,
    '#empty' => t('nothing!'),

);


texts: What is it called when a Drupal Module installs with several modules?

texts: I looked up submodule, but that seems to be a Git thing. So, when a Drupal module installs with a whole group of things that show up in the dashboard, what is each piece called? For example, there are about 8 items that show up in Modules -> Chaos Tool Suite. If they show up in one group, does that mean they are all written by the same entity?


texts: How to hide the text format field set using css?

texts:
I followed several recommendations and decided to go with using CSS to hide the text format. I don't want to use another module to do something minor like this. Just want to hide text format for this particular form.

When I look at source I see:

<fieldset class ="filter-wrapper form-wrapper" id="edit-conditions-format">
blah blah blah
</fieldset>

Then on top of my form render function I do:

drupal_add_css('
        #edit-conditions-format {
            display: none;
        } ',
      array('group' => CSS_THEME, 'type' => 'inline'));

I have cleared cache and the text format is still available. Any tips?


texts: Change the images URI values within an array

texts:
In a custom module of services 3.x Drupal 7 that queries the database, I get the values of the URIs of some images within some nodes.

This is part of module:

$res = db_query("SELECT node.nid AS nid, node.title AS title, body.body_value AS body, fm.uri AS uri
FROM {node} node
INNER JOIN {field_data_body body} ON body.entity_id = node.nid
INNER JOIN {field_data_field_header_image header} ON header.entity_id = node.nid
INNER JOIN {file_managed fm} ON fm.fid = header.field_header_image_fid
WHERE ((node.status = '1') AND (node.type IN ('tiendas')))
ORDER BY nid DESC");

foreach ($res as $cupon) {
$resultados[] = $cupon;
}
return resultados;

And this the json returned by the web services:

[
 {
  "nid": "6",
  "title": "Negron Beach Bar",
  "body": "
Este es el descuento de Negron
\r\n",
  "uri": "public://negron.png"
 },
 {
  "nid": "5",
  "title": "PizaPuck",
  "body": "
Este es el descuento de PizaPuck
\r\n",
  "uri": "public://pizapuck.png"
 }
]

But I need the full url. Not the URI. The json should look like this:

 {
  "nid": "5",
  "title": "PizaPuck",
  "body": "
Este es el descuento de PizaPuck
\r\n",
  "uri": "http://example.com/site/default/files/pizapuck.png"
 }

If I use this from below I get the url I need (in $path), but I have to put the URI value by hand:

$uri = "public://pizapuck.png"; //by hand
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
$path = $wrapper->getExternalUrl();
}

How can I do to replace every URI value inside the array? I need to extract every value of URI, replace it with the path value, and put it back into the array? I understand this is basic and simple, but my knowledge of php, pdo, ppo and mysql are quite poor. Any help on this matter thank you in advance.


texts: Webform questionnaire with scoring and reports

texts:
I've created several long/multipage questionnaires with webform and I need to have a scoring/rating at the end with the results gathered in a report for the user (preferable in pdf).
But there are no models available that add a scoring per option and/or per form component.

What would be the preferred way to achieve a score ?
Could this be done with Views or with the webform-conditions? or via webform_validation?

Any recommendation or direction is very appreciated as I'm bit stuck now.


texts: How to "close" from view standard taxonomy page

texts:
I made several taxonomy dictionaries and all of them have terms. I use terms for Views generations. But standart drupal functionalaty lets end-user to enter as URL: "site/dictionary name/term name" and get list of materials which were marked by this term.
How I can "close" this page? I do not want end-user to see my materials by this hack.


texts:
I have a problem with getting my module_form_alter to work for hierarchical select. I am running on Drupal 7 and my content type is called mytemp and I'm pretty sure my form-id is mytemp_node_form. I have a taxonomy called ICA which my hierarchical select references to.

I get the following error when I run it:

  Warning: Invalid argument supplied for foreach() in arjmod_form_alter() (line 8 of /var/www/hcms/sites/all/modules/arjmod/arjmod.module)

I would like to have my hierarchical select appear with a fixed row height but I can't get it to work.

This is my code:

<?php
function mymodule_form_alter (&$form, &$form_state, $form_id){
  if($form_id == 'mytemp_node_form'){
    foreach ($form['taxonomy'] as &$vocab)
      if($vocab['#type'] == 'hierarchical_select')
        $vocab['#size'] = 10;
}} ?>

Please point me in the right direction.


texts: Can we have multliple routing.yml files in a single module?

texts:
I have more than 50 menus which I need to create custom.
as per the module structure, we need to create routing.yml in root folder.
but I want to do something like this below:

   myModule
      -  products(folder)
              - routing.yml
              - src(folder)
                - productController
      -  brands(folder)
              - routing.yml
              - src(folder)
                - brandsController.php
      - myModule.info.yml
      - myModule.module

is it way to do achive something like this.

I just want to make code seperation and avoid to add all routes in routing.yml


texts: How to filter Views records by day-of-week, including multiples

texts:
I have a need to filter many records by the day of the week derived from a date-only field in those records (i.e. not today's dow).

I would like a solution that works with views filters, as the wider context is that the view itself is being manipulated in code to supply which days should be included -- note plural. Basically, a paragraph is configured with List(text) fields for the weekdays and during preprocess the view is loaded and the field values 'poked' into the view's value instead of the fixed original value. Several other fields are updated likewise.

If I was doing this in plain SQL I might use DATE_FORMAT(fieldname, "%a") IN ("Wed", "Fri") or something similar. I have looked at various existing modules - views_dates and views_date_format_sql in depth - and have noted D7-only views_dow. However I can't quite see a way forward using those (even as a base), partly because I'm not very familiar with views internals.


texts: How can I access/arrange elements in the {{ content }}?

texts:
I am relatively new to Drupal and have just successfully pulled out a field value and used it to display a custom icon on the page.

Coming from a HTML/CSS only kind of world, I am finding it hard to understand how to do simple things, such as take variables I've created and insert them within the {{ content }} area.

In my specific application, I have a page that NOW looks like this:

Custom Icon 3, Custom Icon 4, Custom Icon 5

{{ content starts here }}

Node Title

Node Subtitle

Custom Icon 1, Custom Icon 2, Custom Icon 3

Image

(page continues)

{{ content ends here }}

What I'd like to do is have the Custom Icons all in a nice line together beneath the Subtitle, but since the 3, 4, and 5 were generated by code, they're outside the {{ content }} block.  Icons 1, 2, and 3 are created by hiding the text value (which is either there or not) and displaying a background image...a totally different method that doesn't work for 4, 5, and 6 because in those cases the value isn't binary, it's got several different values.

I'm not married to any specific method to accomplish this but am curious about how I can "best" make these all line up nicely together, one after another, in that order 1, 2, 3, 4, 5, 6.

I believe it's relatively easy to do it like this:

1, 2, 3, 4, 5, 6

Node Title

Node Subtitle

Image...etc.

But that's not really what I'd like to do.  This is how I'd like it:

Node Title

Node Subtitle

1, 2, 3, 4, 5, 6

Image...etc.

This would be relatively easy to do with CSS if I had better access to the inside of the {{ content }} and could make a div, assign it a class, place it in the "4" position, and style it to show as with 1, 2, and 3.  But I don't see how to actually accomplish that when the variables are OUTSIDE that immutable {{ content }} block.

Any help to better understand this process? Even if it is to say that I did everything bass-ackward and should simply make these icon fields images and upload the right image into the field each time. I have a site with a large amount of content on it but not so large I couldn't redo this Content Type from scratch the right way. It just seems so strange to me that something so easy to accomplish with a little PHP has been so difficult to get right in this case.

I've done CONTENT with
Drupal for years, but this is the first time I've been delving deeper into the development side.  Most of the documentation assumes a level of D7 knowledge that I don't have, and the explanations are aimed at people who have been developing D7 sites and need to know the differences, rather than at someone coming in fresh. Or instructions are for D7 entirely.


texts: How to properly works in Chrome as a Drupal administrator?

texts:
Not sure if is there I can do from the Drupal side, then I'll close this question if not suitable here...

I use Chrome to admin my drupal sites and I noticed that after some hours (let's say 3 or 4 hours) the site start to take more time to load admin pages. I resolve this by clearing the Chrome cache. This is ok but then I loss all stored data in Chrome.

Is there I should do within the drupal configuration to avoid this?


texts: How do I programmatically add an image while programmatically creating nodes?

texts:
I'm writing a script to add nodes programmatically, and I don't know the proper way to add/attach image. Actually I'm not that familiar with Drupal.

Here are the (sample) image objects I found while print_ring the existing $node I'm using:

field_image: Array ( [und] => Array ( [0] => Array ( [fxid] => 3089 [alt] => [title] => [width] => 95 [height] => 126 [uid] => 249 [filename] => helloworld.jpg [uri] => public://helloworld.jpg [filemime] => image/jpeg [filesize] => 3694 [status] => 1 [timestamp] => 1346748001 [type] => image [media_title] => Array ( ) [media_description] => Array ( ) [field_tags] => Array ( ) [field_license] => Array ( [und] => Array ( [0] => Array ( [value] => nothing ) ) ) [metatags] => Array ( ) [rdf_mapping] => Array ( ) ) ) )

The next one I found is the following.

field_temp_image: Array ( [und] => Array ( [0] => Array ( [value] => http://www.example.com/sample-path/helloworld.jpg [format] => [safe_value] => http://www.example.com/sample-path/helloworld.jpg ) ) ) `

How should I add an image to that node in that way?


texts: WYSIWYG editor not displaying buttons and plugins

texts:
I'm new to drupal and have not found an answer on SO yet.  I've updated to drupal 6.28, not ready to update to D7 yet, and the WYSIWYG and TinyMCE are not displaying.  Also I can't click/unclick checkboxes for buttons and plugins because I don't see checkboxes!  I also can't

Using TinyMCE 5.3.8. Other User Interface modules my site has are Superfish, jQuery plugins, IMCE Wysiwyg API bridge

Screenshots below.  Thanks!

http://imgur.com/UAZhxtZ

http://imgur.com/YX41wLF


texts:
I get the above error after a creating a new content type.

  Warning: explode() expects parameter 2 to be string, array given in menu_node_submit()

The function which gives error is shown below :

function menu_node_submit($node, $form, $form_state) {
  // Decompose the selected menu parent option into 'menu_name' and 'plid', if
  // the form used the default parent selection widget.
  if (!empty($form_state['values']['menu']['parent'])) {
    list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Adds menu options to the node type form.
 */


texts:
I'm trying to make a related news block on a term page instead of a node. I've done it on a node and it works fine, but when I try to do it on taxonomy term page it makes the whole block disappear.

This is what I have in the contextual filters and what I'm using as my relationship,

and here's whats in my taxonomy,

and this is what's in my content: nid

and finally whats in my relationship.


texts: Are all updates (revisions) to a user recorded in the logs?

texts: A user was created just over a week ago and at some point was given a particular role by an administrator. Will this update (the role given, the date/time of the update and the admin who made it) have been recorded by default in the database somewhere? I don't have any special user modules installed on the site e.g. User Revisions. When I tested just now by giving roles to a user and then looking in "recent log messages" (filtered to "user"), my update didn't show there, so I'm guessing the answer's no, but if there is a way to retrieve this info it would be helpful.


texts:
I've fetched the main menu for the website using the code below.

public function build() {
    $menu_name = 'main';
    $menu_tree = \Drupal::menuTree();
    $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
    $parameters->setMinDepth(0);
    $tree = $menu_tree->load($menu_name, $parameters);
    $manipulators = array(
      array('callable' => 'menu.default_tree_manipulators:checkAccess'),
      array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
    );
    $tree = $menu_tree->transform($tree, $manipulators);
    $build['menu'] = $menu_tree->build($tree);

return array(
      '#theme' => 'allofus_menu_footer',
      '#build' => $build,
    );
  }

I'm trying to put it as a block, but I want to show it as a 2 coloumn. In the first coloumn, first main menu and its sub menus and the rest of main and sub menus in the second coloumn.

I've created a twig but it does not print anything except markup. I've tried to foreach but it is not working.

allofus-menu-footer.html.twig:

{% if build %}
    <nav id ="secondary-menu" class="navigation" role="navigation">
        {{ build }}
    </nav>
{% endif %}


texts:
In the admin content form (admin/content), I am trying to remove links to content page on some content types in a custom module with the following code but I can't get it working.

/**
* Implements hook_form_node_admin_content_alter()
 */
function MYMODULE_veilleur_form_node_admin_content_alter(&$form, &$form_state, $form_id) {
    foreach ($form['admin']['nodes']['#options'] as $option){
      if($option['type'] == "Document"){
        $option['title']['data']['#type'] = "text";
        unset($option['title']['data']['#href']);
      }
    }
}

With this code, I still have the links in the content title. Any idea?


texts: Storing data for every country for an interactive chart

texts:
I need to store one and possibly more values for each and every country so that I can populate an interactive SVG world map. This data will be updated often by hand by one of the content moderators. So it should be easy to maintain by someone with basic drupal content editing knowledge.

So far I have tried:

My initial work had me use a Field Collection, in which I had a dropdown field with all the countries, and another dropdown to select which data point to use for that specific country. This works, but gets extremely memory intensive as the country goes up. It becomes exceptionally difficult to find a country as well since they are not in alphabetical order. I attempted to create each Field collection item prefilled for each country upon creating the node create form. but I would constantly run out of execution time, with it taking more then 4 minutes to get to 200 countries, and getting exponentially slower as the country count went up. Never managing to get to 250.
I then tried to use TableField, and import the data from a CSV, with one column for the iso2 code, one for the name, and one with the numerical value for the value on the chart. This was okay, but nearly always crash when trying to import an updated version of the csv. It also was difficult to ensure the integrity of the country codes and names, since anyone could easily make a inadvertant change when modify data. This would then break either the map, or the translation of the names.

So my question is, how can I go about structuring a content type, so that I can list all the countries and set a value for them which I can choose from a select list, that allows me to view the data, sorted by country, and doesn't bring the browser to a standstill?

Note: I'm using Ammaps to display the data on the front.


texts: Unable to add Acquia Cloud site using Acquia Dev Desktop behind a proxy (Win 7)

texts:
I'm trying to use Acquia Dev Desktop 2 Beta behind a proxy at work (Win 7), but there doesn't seem to be any proxy configuration settings for the program.

When I try to log in to Acquia cloud, it times out and says:

  Login failed.
  Network error: Couldn't connect to server

Has anyone figured out how to make this work through your proxy?


texts:
I'm getting into the FAPI ahah property and I was wondering if there is a list of all the "standard" possible effects that would be available for use without adding any modules (i.e. additional libraries).

Thanks!
Stephanie


texts:
I have a multilingual site and I need to know which nodes are the translation of the current one; I use translation_node_get_translations(), but it seems it doesn't work.

I have 2 nodes (node/17 and node/670) where the latter is the translation of the former.

If I call translation_node_get_translations(17), I get an array with 2 elements referring to the nodes with ID equal to 17 and 670; if I call translation_node_get_translations(670), I get an empty array.

Is that a bug, or do I have to differently retry this information?


texts:
I have following Html code, I want to rewrite two field .1st is  [field_poster_hover_image] and 2nd is [field_team_image] .This is my HTML Code.

and I have written code like this but its not working


texts:
Within my custom module i've got an optional implementation to the dynamic entity reference module: https://www.drupal.org/project/dynamic_entity_reference

When the module exists, I add a DER field to one of my custom tables during the module installation.

The issue i am currently facing is that I can not manipulate the installation order of my module. Within the install hook of my module i am using module_set_weight("mymodule",1).
However this is not effecting the installation order at all when I run drush config-import order or drush site-install --config-dir="/my/conf".

Within my core.extensions.yml the weight got applied after config export:
drupal_content_sync: 1


texts:
I should upload an Excel file to a site that define a content type with a file CCK field; the download method is public. How do I set the permissions for the upload folder, if I would like to allow the PHP code to read this file, without to allow users to read this file using its URL?
If the folder permissions don't resolve this problem, which module should I use?


texts: Theme is not working when files are uploaded from localhost to the web server

texts:
I have finally made it to point where i think it's ok to upload my work from localhost to a web server of mine.

I tried to upload my work from localhost to my web space (on hostgator).

My problem is that Drupal seems not to recognize the theme that is supposed to be used, including not identifying some custom template files I have written for views and nodes.

Same things work ok on localhost and page source code is generated ok (i.e. the correct path img src="http://localhost:8888/drupal/sites/all/themes/simpler/logo.png" is generated for my logo (custom)) but the same thing when uploaded on web server is not working and the path for img src is not generated at all in the page source.

I have several other problems, like custom tpl.php files (for nodes or views) are not used at all, i guess because the system for some reason does not reach (?) the /sites/all/themes/simpler .

I have tried flushing caches with no luck. Also, found some posts suggesting go clicking the 'Save changes' button in theme admin screens but no luck with this too.

If this means something, i have uploaded the whole 'drupal' folder from my localhost to my web server and switched the settings.php to point to my web servers db, which was created by importing .sql file (exported from my localhost).

Hope this whole thing makes sense and someone could help or point me to a direction.


texts: Custom Module Route run by External Cron Task

texts:
I created a Drupal 8 module that cURL to a SFTP, grab a xml file and write it on the files folder. This module as a route (with _access: 'TRUE'), pointing to a controller that does the task.

While I'm connected as admin, and go to that route URL, the XML is downloaded as expected. When I do it as an anonymous user, it doesn't work, not throwing any error.
My goal is to have this route run by an external Cron task (every 5 minutes). However, when it runs, it's not recognized as admin, so it doesn't work.

What would be the best practice to have it working with a Cron Task but also secure enough so that not everybody could run it by going to that URL ?


texts: How to email the results of a filtered view to a user?

texts:
Required functionality (Drupal 7):

User filters a view to desired results
User enters email address in a
webform block
User is emailed the filtered list of results

I'm using Views (7.x-3.14), Webform (7.x-4.14) and Rules (7.x-2.9)

I've looked at a few modules surrounding saving your search results, but nothing I've found seems to help very much. Are there a combination of modules that I might be able to use (Rules, Cron etc.) that will achieve this or do you think I'll need to write something custom?

I'm still learning how to write custom Drupal modules so if anyone can point me in the right direction, that would be appreciated !


texts: I have installed ajax comments module. There is a "reply" link to show comment reply form. I want to show comment reply form under comments without click reply link. Is it possible?


texts: HybridAuth hide additional information form for twitter

texts:
I'm trying to integrate hybridauth module for social login. Its working fine for Facebook.

But for twitter, after successful sign in, its asking E-mail, first name, last name & gender details.

If I uncheck required information, I won't get email to create user in back-end.

How can we do set up in twitter side to get these details?

Or

Is there any way to get these required informations with out showing the form?

My intention to successfully login into Drupal site after sign in using twitter, with out asking any addition informations.

After sign in I'm getting below form (Want to hide this form):

Drupal back end setting (If i hide, above form wont come but can't get email ID and other details):


texts: How to avoid invoking the same module every time when I have to call a function of that module in Drupal 7?

texts:
When there is a need to call a function inside a module, some of you say- it is good to use module_invoke() inside the template pages to call the function(it looks great-since I can pass arguments too).

Using Drupal 7. So for the first time, it is okay. Even for the second time, it makes a bit extra effort in the code, but somehow I can manage it.

Now it is invoking again and again, the same module. Say if the module is block, and the function is hook_block_view()- I doubt, it could affect the Drupal site performance(the time for loading the page contents), what do you think?
Is there a solution for this problem?

<?php
  $header_block = module_invoke('block', 'block_view', '2');
  print drupal_render($header_block);
  $news_block = module_invoke('block', 'block_view', '3');
  print drupal_render($news_block);
  ...
  ...
  $footer_block = module_invoke('block', 'block_view', '12');
  print drupal_render($footer_block);
?>

Is it a good idea to use the module_invoke() every time when I have to call hook_block_view() with different arguments?
Is there any other function that can be used for calling the same function or any other function in the module after one- module_invoke()?
Is there any other way of doing thing?


texts:
I have a custom content type, with an associated block, which all displays correctly.
The block is initially hidden, upon clicking a button the block is moved into view, and the user is able to scroll horizontally through each content item.

Each content item contains an image, so I am interested in preventing them from being loaded initially, and only when the button is clicked (in order to reduce initial loading time).

I don't suppose there is a Drupal way of doing this?
The only way I can think of is making direct calls to the database, which I don't want to do for obvious reasons.

I noticed a "Use Ajax" option in the Views interface, however I wouldn't have thought this would work with my custom jQuery code?


texts: How to select nodes of a certain type, created by a certain user and which have reference field to a node equal a certain nid?

texts:
function mymodule_get_nodes_by_user_referencing_nid($type, $userid, $referncenid) {
    return node_load_multiple(array(), array('type' => $type, 'uid' => $userid, ??? => ???));
}

I need a function that lists nodes by following this logic: give me all nodes of a given type which are created by a given user and which have a node reference field referencing a given node id.

Any ideas about such function (in PHP, not in Views)
)?


texts: Overriding default hashing mechanism: cannot redeclare user_hash_password()

texts:
I have a project that requires a change in the default password encryption mechanism.

The documentation of password.inc states that this can be overridden using the password_inc variable. I followed the instructions as stated in the documentation but when trying to change a password on the website following error is generated:

  Cannot redeclare user_hash_password() (previously declared in
  /.../drupal7/includes/password.inc:207) in
  /.../drupal7/sites/foo/modules/custom/foo_custom/includes/foo_custom.password.inc
  ...

I have searched the code for a hardcoded include on includes/password.inc but can't find anything.

Any ideas?


texts: How can I get a user's language from their e-mail address in PHP?

texts:
I'm using the Mime Mail module to send HTML e-mails to my users.  I have created a template, mimemail-message.tpl.php, and placed it in my theme's directory.  This template defines header and footer links and is applied to every outgoing e-mail.

However, I have a multilingual site and I want to customize these footers per language.  My PHP skills are limited but I'm fairly confident I can do this with a switch statement if I can get the e-mail recipient's language.

I'm having trouble figuring out how to get the user's language.  The Mime Mail module provides a variable, $recipient, which is set to the e-mail address of the user.  Is it possible to load a user based on the e-mail address and then get the user's language?


texts: I have created some menus with menu block module and placed it in my Drupal 6 site's left sidebar, also used menu icons module to put icon for each menu. But the end result is not satisfying. It demands more padding and text resizing to make it attractive. Can anyone suggest some other technique to add icons for menus in Drupal 6.


texts: Is there a way to restrict access to a calendar page excepting the owner of the content?

texts:
I'm pretty new to drupal and I hope to get the solution here. Goes like this: I have a content type named "property" and a calendar attached to each node of this content type. In the permissions section the calendar has "Access bookable item's calendar" which controls who has access to the calendar pages. One of the roles "propertyadmin" has this permission set. Now comes the problem - All users having that role has the same permission and can edit all other calendar pages. I think the problem is here in the calendar module because it doesn't have any conditional logic to check whether the user accessing the calendar is the owner of the referenced node.

Can anyone help? Here is the code:

`  function property_calendar_menu() {
  $items = array();

  $items['admin/property/items/%property_item/calendar'] = array(
    'title' => t('Calendar'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('property_calendar_admin_form', 3, 5, 6),
    'access arguments' => array('access property_item calendar'),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'includes/property_calendar.admin.inc',
  );

  $items['node/%node/calendar'] = array(
    'title' => t('Calendar'),
    'page callback' => 'property_calendar_overview',
    'page arguments' => array(1, 3, 4),
    'access callback' => 'property_calendar_overview_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 4,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'includes/property_calendar.admin.inc',
  );

$items['custom_calendar/ajax'] = array(
    'title' => 'AHAH callback',
    'page callback' => 'custom_calendar_status_ajax',
    'page arguments' => array(2, 3, 4),
    'delivery callback' => 'ajax_deliver',
    'access callback' => TRUE,
    'theme callback' => 'ajax_base_page_theme',
    'type' => MENU_CALLBACK,
  );

  return $items;
}

/**
 * Access callback for overview form.
 */
function custom_calendar_overview_access($node) {
  // Foreach field.
  foreach (field_info_fields() as $field) {
    // If field is entityreference, targets a property_item
    // and it belongs to a node.
    if ($field['type'] == 'entityreference' and $field['settings']['target_type'] == 'property_item' and isset($field['bundles']['node'])) {
      // If current node's type has this field.
      if (in_array($node->type, $field['bundles']['node'])) {
        return user_access('access property_item calendar');
      }
    }
  }

  return FALSE;
}
`


texts: Overriding migration source URL with hook_migration_plugins_alter

texts:
In D8, using Migrate Plus (8.x-4.0-beta3), i am pulling in xml records from an external, non-Drupal API. I have an unwieldy source URL that needs to be passed dynamically to the migrate_plus migration YML file. That doesn't seem possible, but I have read in comments that you can alter the source URL of a migration  with hook_migrations_plugins_alter. However when i do something like below, the URL does not change.

function my_module_migration_plugins_alter(array &$migrations){

  foreach ($migrations as $id => $migration) {
    if ($migration['id'] == 'my_migrate_id'){
      unset($migrations['source']['urls']);
      $migration['source']['urls'] = 'http://example_api';
    }
  }
}

I realize I may need to override the source plugin; if this is true what method do i use to alter the source url?


texts:
I've got a content type article. I display them on a view blog.

I'm customising the display via views-view-fields--blog.html.twig. I'd like to display the author and date fields (they are configured in the view). The other fields display fine, but how do I access those two?

    {{ fields.field_image.content }}

        Posted by {{ ??? }} | {{ ??? }}

{{ fields.title.content }}

{{ fields.body.content }}


texts: Envoking a web service method with hyperlink

texts:
I have successful connected website with a web service SOAP. The SOAP PHP library is working great.
So far I've used a forms that corresponds with the web service, but now I want to invoke a specific method of the web service by clicking on some link.
For an example, the web service has a method "Logout" and I want to pass the xml string after clicking on user/logout.
How can I do that?


texts: how to add new fields in form builder module though custom module

texts: I am new to drupal, I want to add my own fileds into Form Builder module though my own custom module. Please help me whether is there any hook to add new fields in to Webform/Form Builder module from custom module.


texts: Is there a way to get (and use) an environment variable in a template file?

texts:
I would like to add a JavaScript call to my html.html.twig file, but there are two separate .js sources depending on which environment I'm on (production, and non-production). I believe Acquia Cloud (which we use) provides such variables, but they are for PHP.

I'm still relatively new to Drupal 8, so I might be missing something obvious with this. Is there a way to use Acquia Cloud's environment variables in a template file?

I forgot to mention that I tried accessing the environment variables from a few preprocess functions, for example themename_preprocess_html() and themename_preprocess_page(), but they are apparently not set at all.


texts:
I just started my project which I haven't touched in a while. I got the most recent develop version of it using git and I up'ed my docker. Once I opened my website I saw, that something is off. Console is saying that "Drupal is not defined" and if I visit pages-> --any page-- -> content, the layout is off.

In the console here it says ReferenceError: jQuery is not defined.

What I already tried to do:

Rebuild my project
Resave configuration of jQuery update
Clearing cache (lol)
Checking if JS is enabled on my browser

Can someone help me out please?


texts: How do I limit or require the number of tags in a taxonomy reference field?

texts: Similarly to how StackExchange requires tags on a question, how can I ensure the user uses at least four tags but no more than 8?


texts: Delete hundreds of nodes by ID programmatically

texts:
I am trying to remove 700 or so nodes from my Drupal 7 system (they are duplicates) and have a big list of node IDs in a text file.

Have tried using Views Bulk Operations (VBO) but it doesn't allow me to enter a list of IDs.

Also looked at using Drush documentation, but it doesn't seem to have a node-delete command? (surely a pretty standard thing?)

So now I'm thinking of writing my own Python script to do the following:

Take list of input IDs (via input file)

(note: this is just pseudo code)

# remove nodes
Foreach id in file_in_ids:
   SQL(DELETE FROM node WHERE nid={id});

# clean up all rows in tables containing col 'entity_id':
tables_with_entity_id = SQL(SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME
IN (
'entity_id'
)
AND TABLE_SCHEMA = 'my_drupal_db')

foreach table_name in tables_with_entity_id:
  foreach id in file_in_ids:
    SQL(DELETE FROM {table_name} WHERE entity_id=id)

Does this seem like a sound approach?


texts: How to create a list of users who did not submit some webform?

texts:
I have a webform expecting all users to record their data online.

I would like to list all users who did not submit the webform yet.
I have been trying to use Views, but I cannot find a way to do that.

To list users who have submitted is not a problem, just display the users submitting in Views table.

How can I list all users who did not submit the webform?


texts: Own exposed filter can't use LIKE and REGEXP in one query

texts:
I'm working on a own views3 filter which should include wildcard search with '*'. This is working pretty well if you search for one word (for example "test*" or "*test"). But I had the idea to include word search to. Which is, if you type in two words, is searching for both whole words. This is using REGEXP to go for it. All alone, this is also working well. But if I am searching for "test* more", there is no result even if there should be some results. Here's what I am doing so far:
If there is no star in the search word:

$placeholder = $this->placeholder();
$this->query->add_where_expression($this->options['group'], "$field REGEXP '[[:<:]]".$searchit."[[:>:]]'");

And if there is a star in the search word:

$searchstring = explode('*', $searchit);
$placeholder = $this->placeholder();
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($searchstring[1])));

Can't drupal handle REGEXP and LIKE in one query? Cause for itself, it is working, as I said before. Or am I doing something wrong.
If the code isn't enough, I could post the whole module.


texts: Drupal configuration on non root url (how to change $base_url)?

texts:
sorry for my english, I'm french

ok, that's I want to do is to install my drupal site on a url like :
www.mymachine.fr/mydrupal/

and the problem is that when I go this url,
he dispatch me to www.mymachine.fr/core/install.php
instead of www.mymachine.fr/mydrupal/core/install.php

so the install doesn't work

My conf is like this : debian server

in drupal file "sites.php", I have this :

$sites['mymachine.fr.mydrupal'] = 'mydrupal';

on /etc/hosts, I add this line  :
    127.0.0.1    mymachine.fr.mydrupal

on /etc/apache2/sites-available/000-default.conf :

<VirtualHost *:80>
    ServerName mymachine.fr.mydrupal
    DocumentRoot /var/www/mydrupal/CORE-DRUPAL8-WEB/web

    ServerAdmin webmaster@localhost

    # Log configuration
    ErrorLog ${APACHE_LOG_DIR}/drupal-error.log
    CustomLog ${APACHE_LOG_DIR}/drupal-access.log combined

    <Directory "/var/www/mydrupal/CORE-DRUPAL8-WEB/web">
            Options FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

</VirtualHost>

SO I don't know if it's drupal configuration or apache configuration to change $base_url from drupal site ...
thanks a lot


texts:
I have a file that I have bootstrapped and I am trying to print messages but I can't get it to work. Here is the code does anything look wrong (mysite was changed)?

<?php
define('DRUPAL_ROOT', '/home/mysite/public_html');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
?>

<html>
<body>
 <div class="description">
  <?php global $user;

     print "Welcome " . $user->name;
     drupal_set_message(t("Don't panic!"), 'warning');
     print $messages;
  ?>
</div>
</body>
</html>


texts: Drupal Commerce payment transaction: execute script and pass variables

texts:
When you need to create a new transaction method for Drupal Commerce, you need to dive into the code. And that's something I have zero experience with. BUT the following couldn't be hard. I already created a new payment module (just copied and edited the payment example module so I have a new payment method).

In commerce_payment_example.module you have the function commerce_payment_ideal_transaction that is been executed by the submit button of the checkout form. The only thing I need to do is to execute a script on submit (in HTML you can do this with <form method="post" action="script.php">, and pass three variables with it: the amount ($charge ?), the order ID ($order->order_id ?) and a description ($order ?). Could someone help me on the right way?


texts:
In Drupal 7 we could clear a cached URL with the following.

$url = url('<front>',  array('absolute' => TRUE));
cache_clear_all($url, 'cache_page');

What's the equivalent in Drupal 8?


texts: Max File Upload Size set to big, but Ajax Error with old file size

texts: I have changed the upload_max_filesize and the max body size in my php.ini to 15 MB. It used to be 2 MB. Drupal displays the max file size correctly, but when I try to upload files bigger than 2 MB - the old limit - I get an Ajax Error, telling me the entity is too large. Any idea where this comes from?


texts: How to force Local Task Menu to display on specific pages

texts:
I’ve made a tabbed display out of my Local Task Menu as imaged.

Some of the extra buttons are ‘pages’ as made with ‘pages manager’  .  Here you can assign the page to the Local Menu; when doing so by this method the created page also shows with these user tabs.

However a couple of pages ( one created by the Nodequeue and the other a Custom Module made by myself ) ; with these I’ve assigned to MENU_LOCAL_TASK  in hook_menu_alter   .  And although they show up in the menu when clicked on they no longer have the Local Task Menu.  Does anyone know a way I can force these pages to show it ?

Many thanks


texts: Possible parent values for parent of links

texts:
I am trying to create links in my Drupal 8 module, following this tutorial. So far, I have a link as follows in my module.links.menu.yml file:

module.admin_settings:
  route_name: module.adminForm
  title: 'Module Configuration'
  description: 'Set up module on your website'
  parent: system.admin_config_system

My question is, how do I find all possible values for the parent property? I looked in the docs but couldn't find one. However, there is a paragraph in the above tutorial which says:

  Determining the parent menu_link name can be a little tricky at first.
  If you know the path of the parent menu item, you would need to search
  for it in all available *.routing.yml files (most text editors and
  IDEs should allow you to search all files in a project) and find the
  route name for that path. Then, you would need to search for the route
  name in all available *.links.menu.yml files. The menu_link whose
  route_name matches is your link. Alternatively, if you know which
  module is defining the parent menu link (or one of the parent menu
  link's children), you can go straight to that module and perform your
  search.

But I am not sure I understand as I am new to Drupal. Is there an easy way to find the set of possible parent values?

Thanks.


texts: How to theme simplenews unsubscribe page?

texts:
I'am trying to theme Unsubscribe Page for my Newsletter to much the Newsletter Design.
Does anyone know how to theme unsubscribe page in Drupal 6:

example.com/newsletter/confirm/remove/*


texts: How do you refer to the field in views-view--field-fieldname.tpl.php?

texts:
I'm using the views-view-field--field-fieldname.tpl.php to rewrite the output of a specific field in a view. However in this template I'm having trouble referring to the actual field.

I can produce the normal input with

print $output;

However this contains the classes and divs it is wrapped in. Including the default icon that is used to represent it. I'm having trouble producing the specific data of the field. Specifically the url to the file. (It is a file field). Is this possible? I made quite a number of attempts. Below are the attempts I've made that were unsuccessful.

print $fields['fields_field_fieldname']->content;

print $row['fieldname'];

print $view->results->{view->field['field_fieldname']->field_alias};

I understand that I could use string replace and regex to extract the data I need $output. If that's the only way to do it, I'll stick to that.


texts:
I have installed drupal 8 .

During installation i am getting the below error

Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):

fileinfo

Which i have solved by uncommenting "extension=php_fileinfo.dll" in php.ini file.

But after successfully installation i am getting connection reset issue like url is not found.

I know d8 is not stable version.

Still some users working/posting issue.

How they able to work on it?

Please suggest is there any alternative link to download d8.

Thank you.


texts: Create a block with contextual filter that show related nodes based on field value, not with taxonomy

texts:
I'm no newbie to Views or Argument/Contextual Filters, but I'm having trouble getting my head around a (simple) view.

I've created a Content-type "Event".
Which contains an 'Addressfield', which I use to store an Address and Geocode it to an value which I store in Geofield.

What I'm trying to accomplish is a 'related nodes' block, similar to an 'related articles' based on taxonomy. In that case you make a relationship, and use the NID in de URL.

I've created a View:
- a block style.
- added a 'contextual filter #1':
- When Filter value is not available: 'provide default value', content id from URL.
- Extra: exclude. This filter excludes the current node.

I'm having trouble getting to the next step: I only want to show the nodes which have the same country as the current node. How do I accomplish that?

So if I'm visiting a node from 'France', I only want to show related nodes from France.


texts: why do I receive wrong Notice: Undefined index?

texts:
There is a view and content type both called activities and this is views-view-fields--activities--block.tpl.php

<?php print $fields['field_activities_image']->content;?>

<?php print $fields['field_activities_title']->content;?>

<?php print $fields['field_activities_summary']->content;?>

this block is displayed in the front--page.tpl.php and it works right.
There is another block of this view and that block is displayed in the node page. this block only contains 10 title. the problem is drupal reports this warning in the node page:

Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_image in include() (line 2 of ...views-view-fields--activities--block.tpl.php)
Notice: Undefined index: field_activities_summary in include() (line 5 of ...views-view-fields--activities--block.tpl.php)

The ID of the block that is displayed in the node page is block_1 but it tries to use views-view-fields--activities--block.tpl.php. how can I solve this warning?


texts: Retrieve reference to content type in preprocess

texts:
I have a content type (let's name it Wheel for an example) that have a field referencing an other content type (which could be Car, Motorbike, Bicycle ...).
So a node named WheelMotorbikeBrand whould reference the content type Motorbike.
I would like to retrieve the value of this field in a preprocess with something like $node->get('field_wheel-type') but I'm not able to obtain a value.
How can I retrieve the value of my field ?


texts: How do I get a list of Drupal 7 active contexts for the current page/form in hook_form_alter?

texts:
I have several contexts defined for my site. In hook_form_alter I need to find out which of them are active. I am trying to use context_active_contexts, but that is only showing 2 of the (at least) 3 that are active. i.e. I have contexts A, B and C. C has a block reaction and the block is visible. My code only outputs A and B. If I disable C, the block disappears from the output, giving me some confidence that it really is context C that is responsible for it. Why can I not see A, B and C in the output?

function MyModule_get_current_location_contexts() {
  $contexts = context_active_contexts();

  $locations = array();
  foreach ($contexts as $context) {
    $locations[$context->name] = $context;
  }

  return $locations;
}

function MyModule_form_alter(&$form, &$form_state, $form_id){
  dsm('Contexts (form):');
  if ($form_id == 'MyForm') {
    $contexts = MyModule_get_current_location_contexts();

    foreach ($contexts as $context) {
      dsm($context->name);
    }

    dsm($form);
  }
}

function MyModule_node_view($node, $view_mode, $langcode) {
  dsm('Contexts (entity):');
  $contexts = MyModule_get_current_location_contexts();

  foreach ($contexts as $context) {
    dsm($context->name);
  }
}


texts: Form textfield AJAX validation "deletes" injected services to form

texts:
I'm trying to create a form that has two services injected (for access to an API) and a textfield with an AJAX callback. Here it is:
public function buildForm(array $form, FormStateInterface $form_state) {
    $form['vat_number'] = [
        '#title' => $this->t('VAT Number'),
        '#type' => 'textfield',
        '#default_value' => isset($address['vat_number']) ? $address['vat_number'] : '',
        '#states' => [
          'visible' => [
            ':input[name="is_business"]' => ['checked' => TRUE],
          ],
          'required' => [
            ':input[name="is_business"]' => ['checked' => TRUE],
          ],
        ],
        '#ajax' => [
          'callback' => '::validateVatAjax',
          'event' => 'change',
          'url' => Url::fromRoute('shop_product.digital_river_payment_form'),
          'options' => [
            'query' => [
              FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
            ],
          ],
        ],
        '#suffix' => '
',
      ];
    }
.....
}
public function validateVatAjax(array &$form, FormStateInterface $form_state) {$response = new AjaxResponse();
    $message = '
';

    if (!$this->customerService->validateCustomerTaxFormat($form_state->getValue('vat_number'))) {
      $message .= $this->customerService->$schema['properties']['value']['description'];
      $message .= '
';
    }
    else {
      $message = '

';
    }
    $response->addCommand(new ReplaceCommand('#errors', $message));
    $form_state->setRebuild(FALSE);
    return $response;
  }

public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state->getValue('is_business') == 1) {
        $vat_number = $form_state->getValue('vat_number');
        if (empty($vat_number)) {
          $form_state->setErrorByName('vat_number', $this->t('Please enter your tax number.'));
        }
        elseif (!$this->customerService->validateCustomerTaxFormat($form_state->getValue('vat_number'))) {
          $schema = $this->customerService->getSchema();
            $form_state->setErrorByName('vat_number', $schema['properties']['value']['description']);
          }
          else {
            $form_state->setErrorByName('vat_number', $this->t('Please enter your VAT number including the two letter country code.'));
          }
        }
      }
}

I omitted some of the code but my problem is that on the second AJAX call to the callback, it fails because the customerService is null. Aside from that, I don't understand why validateForm() is called on the textfield input change. Is this normal for Drupal?
Thanks in advance.


texts: Module's optional field config not imported on install

texts:
I've got a module which contains a config/optional folder which has the content:

paragraphs.paragraphs_type.my_paragraph_id.yml
field.field.paragraph.my_paragraph_id.field_my_field.yml
field.storage.paragraph.field_my_field.yml
core.entity_form_display.paragraph.my_paragraph_id.yml
core.entity_view_display.paragraph.my_paragraph_id.yml

These files have been exported from an existing installation without uuid's. When I enable the module, the config does not import since the module paragraphs has not yet been enabled. When I enable paragraphs the paragraph type my_paragraph_id is created as expected. The field storage for field_my_field is also created, since I can create a new field based on the existing field field_my_field. Though, the field is not created on the paragraph itself.

I've tried moving the config files to config/install and then it simply works as expected; the field gets created on the paragraph just fine. But the module paragraph should be optional and only then the config should be created, therefor, I want it to be optional.

Why does the config/optional not install the field?


texts: Transliteration- Is it possible to transliterate filenames (and update the DB) after files have been uploaded?

texts:
I have a website that allows users to upload pictures.  To reduce the amount of space used by pictures files on my site, I attempted to use a script to remove orphaned files.  However, this script chokes on Unicode file names; there are dozens of pictures with Unicode file names on my site:

  query:You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use
  near 's Adorable Kitty EDIT.jpg'' at line 1

I have enabled the Transliteration module so that new files will not have this problem.  However, what can I do about the old files?  Is there a way to change their names and update the Drupal DB?  I am willing to do this manually if necessary, but I don't know how to approach this.

EDIT: Upon closer inspection, the problem is not unicode, it's the quote marks in the filename.


texts: Connecting site to AWS RDS results in HTTP Error 500

texts:
I've moved my Drupal website over to AWS (using an EC2 instance and RDS instance). Everything moved over just fine. However, when I try and connect my drupal installation to my RDS database via the settings.php file, I get the following message when I navigate to my site IP:

  This page isn’t working [public ip] is currently unable to handle this request. HTTP ERROR 500

Right now, I'm putting my RDS endpoint into the settings.php file's 'host' spot.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'mydbname',
      'username' => 'mydbusername',
      'password' => 'mypassword',
      'host' => 'myrdsendpoint.us-east-2.rds.amazonaws.com',
      'port' => '3306',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

When I leave the host blank, I do however get a Drupal error (as I should). That said, why am I unable to connect to the AWS RDS endpoint? I've even given my EC2 instance's private IP permission to access MySQL in the RDS' security group.

Something to note: When I do a fresh drupal install with the same above specs in the settings.php file, the new drupal site works perfectly (is visible). Could the 500 error be because my instance isn't large enough (e.g. do I need more space or memory?)

Help.


texts: Using breadcrumbs with multiple menus for one link

texts:
In my website I have 2 menus; the Main Menu and the Header Menu that I use for quick links.

I have 1 page that is linked in both menu.

When I'm on that page, the breadcrumb (and other menu-related blocks) use the hierarchy of the quick-link menu.

In my node the menu configured is the Main Menu and I added the link manually to the Header Menu.

Is there any way to give a weight to different modules?

Thanks!


texts: References module doesn't specify/read a pager limit when field is using a view to generate potential references

texts:
Discovered an oddity that seems inherent in the node_reference.module 7.x-2.1. It is a rather specific use-case, so I can see why it might not have come up frequently before. Just wondering if anyone has any work around ideas, either that or I'll document my findings if I reach a solution.

How to reproduce the issue:

Create a reference list view, and use it to power an autocomplete field.
Create another view and attempt to use the created field as a filter.
Everything will work fine, unless that field has a large number of values. The field I'm using has upwards of 90,000 items.
This is because the views filter UI attempts to render all possible values as a checkbox list.

The reason it trips up is because:

function _node_reference_options($field, $flat = TRUE) {

Goes on to call:

$references = node_reference_potential_references($field);

Without any options. Which leads to:

references_potential_references_view(
  $entity_type, $view_name, $display_name, $args, $options);

Being called without any options, and it seems this code does not read the pager settings to get its limit value. Instead it relies on $options['limit'].

$limit = !empty($options['limit']) ? $options['limit'] : 0;
$view->display_handler->set_option('pager', array(
  'type' => 'some', 'options' => array('items_per_page' => $limit)));

I'm not sure which bit of the code is at fault — i.e. who should definite a limit, or read the pager settings — but there definitely needs to be a defined limit and not 0. Especially when dealing with so many possible values. Setting a limit specifically for the pager in Views UI does not work as it is circumvented.

Currently I can't even get to edit my view with the filter specified, unless I hack the references module to pass:

$references = node_reference_potential_references($field, array('limit' => 10));

I'm only adding this as a filter so I can state that the field isn't empty. I could just leave the hack in until I've set the filter to a state that doesn't read the values. However this feels rather unsafe — especially if someone else was to take over the code at a future point.


texts:
I have below query , when it run with non-registered user return null but with any register used with any role has result .
also non-registered user has permission to view any product

$result = db_query("SELECT * FROM {node} node
LEFT JOIN {field_data_field_course_ref} field_data_field_course_ref ON node.nid = field_data_field_course_ref.entity_id AND (field_data_field_course_ref.entity_type = 'node' AND field_data_field_course_ref.deleted = '0')
LEFT JOIN {commerce_product} commerce_product_field_data_field_course_ref ON field_data_field_course_ref.field_course_ref_product_id = commerce_product_field_data_field_course_ref.product_id
WHERE (( (node.nid = :nid ) )AND(( (node.status = '1') AND (node.type IN  ('course_display')) )))
", array(':nid' => $nid));
      $coursePIDs = array();

      //get node product variation

      foreach ($result as $record) {
        $coursePIDs[$record->field_course_ref_product_id] = $record->field_course_ref_product_id;
      }

 ym($coursePIDs);

any idea?


texts: How to get the taxonomy translated in URLs?

texts:
I have a bilingual site with localized taxonomy terms used as categories.

I would like to achieve this:

http://www.mysite.com/about/pageinenglish

http://www.mysite.com/apropos/pageinfrench

(A propos means about in French)

But I only have:

http://www.mysite.com/about/pageinfrench

How can I translate the taxonomy in urls?

EDIT

I have pathauto configured with i18n terms (which are only available in TAXONOMY TERM PATHS)


texts: How to properly render a Calendar view title in a month display?

texts:
I have a calendar view set up as shown in these screen shots. Everything is working nicely, except the title. I'd like the title to be only the month, not the first of the month.

(larger)

That is, instead of the below screen shot reading December 1, 2014, I'd like it to render only December 2014 (omitting the "1st").

(larger)

Is there an answer that I'm missing in the Add Header area?

(larger)

Update: Contextual Filter


texts: Duplicate entry/Contraint violation 1062 in file_managed on browser crash

texts:
I'm using Drupal 7.28. Today when I tried to upload some 100 image files in Image field type, it aborted in the middle saying that "20 MB" limit reached. Now it wouldn't even show me way to delete the files.

Since then I'm getting the following error (below). when I try to upload the same files.

I've run cron and also cleaned all caches but this error does not go.

I can see that these orphaned files are still stored in the file_managed table.

How can I resolve this problem?

Related post: https://stackoverflow.com/questions/8809010/pdoexception-on-duplicate-filename-in-drupal-7

Another solution comment here on Drupal.org which says that such files should be cleaned by 6 hours by Cron run.

Error on repeat uploads

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062
  Duplicate entry 'public://wsgallery/DSC00441.jpg' for key 'uri':
  INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize,
  status, timestamp, type) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5, :db_insert_placeholder_6,
  :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => 1
  [:db_insert_placeholder_1] => DSC00441.jpg
  [:db_insert_placeholder_2] => public://wsgallery/DSC00441.jpg
  [:db_insert_placeholder_3] => image/jpeg [:db_insert_placeholder_4]
  => 305012 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 1413799461 [:db_insert_placeholder_7]
  => image )


texts: Why does not the preview of the loaded image appear?

texts:
When I load an image into a Drupal 8 form, JS errors appear in the console and the file link is not displayed. I have a limit of 10 MB per file in Drupal. If I load an image of 1 MB or less, it works. If I load an image of more than 1MB, it does not load and there are errors in the consoles :

I load an image of less than 1 MB, it works:

I load an image of more than 1 MB, it is a failure (errors in the console and no warning) :

The form fields and my server are correctly configured :

The server and Drupal seem to me correctly set. How can I fix this ?


texts: When using the boxes module, is it possible to export the region and visibility settings?

texts:
I just installed the Boxes module and I added a box to my feature.  The box description and body were exported successfully, but the region settings (where in the theme(s) the box appears) and the visibility settings (show block on specific pages, etc.) were not.

How can I export the placement information for boxes as well?


texts: How to set $base_url when running a site in a subdomain?

texts:
I just uploaded a site to a remote server. The url is a subdomain: mySubdomain.myDomain.com.

The site just shows the front page. If I tried to navigate to other page (ex.: el-graner) I get this message:

Not Found

The requested URL /ca/el-graner was not found on this server.

I set the $base_url variable in sites/default/settings.php in this way, then clear all caches...but not working at all.

$base_url = 'http://mySubdomain.myDomain.com';

What are the settings I need to do when running a drupal site in a subdomain?


texts: Alter menu link path based on content type

texts:
I'm stumped on how to achieve this in Drupal 8 due to the removal of menu related functions. What I would like to do is check whether a menu link points to a node of content type File, and then alter the link path to point to a File field value on node (so that the menu link points to the file itself). I just need help getting to the point where I have both the path/route and the node object. I have tried to do this in menu--main.html.twig, where I can get the node id for each menu item. However there does not seem to be a way to load a node object through Twig and even if there were, I doubt this is the correct way to go about this.

I have found tutorials pointing me to implement alterRoutes(), for example:

public function alterRoutes(RouteCollection $collection, $provider) {
  // Find the route we want to alter
  $route = $collection->get('example.route.name');
  // Make a change to the path.
  $route->setPath('/my/new/path');
  // Re-add the collection to override the existing route.
  $collection->add('example.route.name', $route);
}

This doesn't seem helpful because I do not want to alter the route to the node whenever it is visited. I only want to alter the route when it is visited from the menu.


texts: Twig's slice filter behaves unusual for non English languages

texts:
I have used slice filter to display few number of Japanese alphabets from a sentence.

{{ desc|length > 65 ? desc|slice(0, 65) ~ '...' : desc }}

But sometimes it slices very early when a Japanese full-stop appears and the preceding sentence has long length for full-stop to appear.

I have 3 patterns to show:

1) When I have following text to slice:

  何もほかけっしてその納得学というののために見なん。ちょうど今に話家はまるでその使用ませですくらいが出ているんがは反抗おっしゃれなけれでて、さらににはなっましましなん。主義にみでのはけっして前を余計でですた。

It slices the above thing as:

  何もほかけっしてその納得学というののために見なん。

2) For following string

  同時にネルソンさんに自覚文字当然発展のするでがたある馳何か相当がという実お話しませますたならで、この今もあなたか世の中鷹狩を使いこなすので、岡田さんの事に政府の私にもしご意見と云えて私宅にご記念になさいようにどうしてもご話の始めんたて、最も勢い発音へ云わましてならたのを立つないまし。

It slices to:

  同時にネルソンさんに自覚文字当然発展のするでがたある馳何か相当がという実お話しませますたならで、この今もあなたか世の中鷹狩を使いこ...

which is perfectly sliced to 65 alphabets.

3) For following string:

  教師でしかしネルソン君にまたはそれだけ聞いうのうたう。向さんもさっそく国家をしばした事べくですた。（また考を云っ以上でしょですたてたも間違っあるたらが、）そう好かあり相場を、スコットの冠詞じゃしでみに対して、主義の下宿は前の他まで知れ当る気に行かませて刺戟院叱らて来るですというお自分ないものん。

It slices to:

  教師でしかしネルソン君にまたはそれだけ聞いうのうたう。向さんもさっそく国家をしばした事べくですた。

Is there any way to solve it or any other solution to achieve this?


texts:
I've checked for a similar question but nothing helped me.
So, i want to add a list in shopping cart with 3 options:
a) No discount
b) 70% discount
c) 65% discount
When the user selects, lets say 70% discount, the discount will be added in total amount and after that is going to select the payment method.

I'm doing this because there is no available module for deposit. The 30% of deposit that i want is like 70% of discount.

Thanks and i hope there is an easy solution that i couldn't find


texts: How can I add relative path to a pdf file link in drupal menu

texts: I have created menu link for a pdf file. I can use a full path like "http://website/sites/all/myfiles/file.pdf", but if I try to put a relative link such as "sites/all/myfiles/file.pdf" it does not work. If anyone has idea please tell me.


texts: Get field value and label for a content type using REST API

texts:
I need to create a REST API endpoint with GET operation in Drupal 8. The API should return all fields of a given content type. Right now I am only able to fetch the title.

Also, I am not supposed to use the REST Export option in views module but the expected output is same as what we get using the Views REST Export option.

This is the code I have written for the get() method and right now only title is being displayed. I want to output the remaining fields as well.

public function get() {
    if (!$this->currentUser->hasPermission('access content')) {
        throw new AccessDeniedHttpException();
    }

    $query = \Drupal::entityQuery('node')
      ->condition('status', 1)
      ->condition('type', 'schemes_funds_nav')->execute();

    $nodes = \Drupal\node\Entity\Node::loadMultiple($query);

    foreach ($nodes as $entity) {
        $result[$entity->id()] = $entity->title->value;
    }

    $response = new ResourceResponse($result);
    $response->addCacheableDependency($result);

    return $response;
}

Any help is highly appreciated. Thanks in advance.


texts:
I'd like to replace the link title on the top link of my secondary navbar (called "explorer", links to "mysite.net/explorer", but actually just triggers a dropdown-menu) with a glyphicon and the current user's name.

According to this thread, a title callback is the way to do this. However, adding this code in my template.php has no effect at all.

function mythemename_menu_alter(&$items) {
  $items['explorer']['title callback'] = 'mythemename_title_callback';
}

function mythemename_title_callback($arg1, $arg2) {
  global $user;
  $title = ''. $user->name;

  return $title;
}

What am i doing wrong? And why does the callback function take 2 parameters? (It doesn't work with 1 or 0 params.)

The "menu token" module almost crashed my site after installation, so I don't want to use that.


texts: AJAX callback not added using form_alter

texts:
I want to perform a AJAX callback to check the value of a custom field during user registration. Because the form is already built, I need to use hook_form_alter.

But, no callback is added using hook_form_alter. Maybe it is overwritten later on? Therefore, I tried $form['#after_build'].
But that fails too for the AJAX property. Adding another form element works perfectly fine.

The code:

/**
 * Implements hook_form_alter().
 */
function member_id_check_v2_form_alter(&$form, &$form_state, $form_id){
  switch ($form_id){
    case 'user_register_form':
    case 'user_profile_form':
      $form['#after_build'][] = '_member_id_check_v2_ajax';
      break;
    default:
      break;
  }
}

function _member_id_check_v2_ajax($form, &$form_state) {
  $form['member_id_check_v2_callback_wrapper'] = array(
    '#type' => 'textfield',
    '#title' => t("The default value will be changed"),
  );

  $form['custom_field']['#ajax'] = array(
    'callback' => '_member_id_check_v2_callback',
    'wrapper' =>  'member_id_check_v2_callback_wrapper',
  );

  return $form;
}

function _member_id_check_v2_callback() {
    watchdog(WATCHDOG_DEBUG,'Callback worked!');
}

What am I missing? Thanks in advance!


texts:
I just created the Blocks and Regions in drupal 6. Now I want to align these regions (by using DIV id's etc..), so I created a block-[region].tpl.php file and write HTML and PHP scripts. Unfortunately these scripts are not showing in that regions, only the block contents are showing.

By the article, template files are searched in the following order:

block-[module]-[delta].tpl.php
block-[module].tpl.php
block-[region].tpl.php
block.tpl.php

But the contents in the files are not displaying. How I figure-out this problem ?


texts: How to set an existing database field to auto increment

texts: I have an existing database that has an id field that is an unsigned integer with a length of ten (and is set as the primary key). I would like to write an update to change this field so that it auto increments. How would I go about doing that? I am familiar with writing updates, just haven't done one like this before. I am doing this with Drupal 7.


texts: How to create different Views pages for different taxonomy vocabularies?

texts: I have two vocabularies that require two different taxonomy view pages. For example, I have vertebrates with terms fish, cats and snakes and invertebrates with sea cucumbers, spiders and snails. I would like to create a different view for each. Can I configure Path Auto to create separate URLs passing the vocabulary term ID as an argument? If so then how do I change the link of the Term found in the Term Reference field of the node view to point to these pages? I'm thinking about installing the Taxonomy Views Integrator but would rather leave out an extra module if it's just a matter of configuring a Views argument correctly.


texts: Unsupported operand types in system.module line 2134 when trying to add product with drupal commerce

texts:
I'm trying to add a product to my commerce store, and anytime I navigate to the add a product page I get hit with the following error:

Fatal error: Unsupported operand types in C:\Users\Nick\Sites\devdesktop\psr3\modules\system\system.module on line 2134

I have googles around, and this looks like a common error with contrib or custom modules.

The error happens in this if statement:

  if (!isset($item['mlid'])) {
    $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  }

My php isn't good enough to know what might be causing the error. How can I solve this?


texts: Is there a Drupal 7 function that is equivalent to PHP strip_tags?


texts: How do I apply patch in vendor directory using composer?

texts:
Background:

Drupal 8
Managing dependencies with compose

I want to apply one patch to vendor/behat/web_api_extension project.

I tried with this in composer.json but it doesn't works or no error.

"extra": {
    "enable-patching": true,
    "patches": {
        "drupal/better_formats": {
           "Settings have no affect on the field if it is in a Paragraph bundle - https://www.drupal.org/node/2754029": "https://www.drupal.org/files/issues/better_formats_paragraphs-2754029-15.patch"
        },
        "vendor/behat/web-api-extension": {
            "behat web api definition conflicts with mink extensions": "patches/behat_web_api/alter-definitions-text.patch"
        }
    }
}


texts: image field point to another image field

texts:
I have users whom are part of a group, this group has an image field that can be changed by the administrator.

When a user writes a new article, i wan the article to display the image of the group.
To do so, i'm modifying the hook_node_presave(). I'm loading the group of the user and i modify the image of the article to match the one from the group with a simple affection ( $node->field_image = $userGroup->field_image_group; ).

It's working pretty well, however if the group changes its image, the article will still keep the old one.

Is there a way to make the image change automatically ? Same question if I change the author of the article or if the author changes group.

Thank you.


texts: Hook to catch a variable in a POST request to a specific url?

texts:
I'm testing an external email collection service that appears periodically at certain time intervals on a site.

When a user completes the form, the application can pass the email address as a variable in a POST request to a specific url.

What hook should I use to catch and process the email address at this one specific url?

I thought of using hook_init() something like the following, but I'm not sure if this is a good way to do something like this?

/**
 * Implements hook_init()
 * Check for variable sent via POST and process if found
 */
function mymodule_init() {
  if (drupal_get_path_alias() == "myurl") {
    if (isset($_POST['email_variable'])) {
      <custom processing>;
    }
  }
}

Notes:

The url is a normal node page that already exists on the site.
The form is externally hosted, so a form alter is not an option.


texts: How do I create a static block programmatically?

texts:
I want to create a static block using a module. I do not want to use the Views module to create a block. Could anyone explain me how to create a static block programmatically?

I have already checked the example modules in Drupal, but it didn't help me much. I have started Drupal module development every recently and I am struggling to do this.


texts: hook_menu() not available for ajax loaded links

texts:
I'm loading a datatable and its data into a panel, through ajax. Below is the link which can add the row(entry) to favorites. When I click the link, the jquery animation is executed properly but the hook_menu and it's callback function is not being executed. It looks like the hook_menu is not 'available'

This is the link

$link = array(
    '#type' => 'link',
    '#title' => t('Favorite'),
    '#href' => 'favorite/' . $item->nid,
    '#attributes' => array(
    'class' => array('use-ajax', 'favorite_item_button'),
    ),
);

And this is the hook_menu

function favorite_item_menu() {
  $items = array();
  $items['favorite/%'] = array(
    'title' => 'favorite item',
    'page callback' => 'favorite_item',
    'page arguments' => array(1),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

Do you see any mistakes? Am I doing something wrong, forgetting something?

Advice is much appreciated.

Edit:
- no php error logs
- no js error logs

tried: sitename.com/favorite/501 - got the error 'access denied'


texts: Must at least one bundle have the same name as the entity in hook_entity_info()?

texts:
I'm working with hook_entity_info, and I'm defining an entity which will have multiple bundles.

Do I need to define a bundle which has the same name as the entity, or will the base entity become entirely "abstract" once I define entity bundles?

In the below piece of code, I've defined a setting entity which has the bundle generic. Should generic really be called setting, or can i completely regard the entity as an "abstract" concept?

function settings_entity_info() {
  $info['setting'] = array(
    'access callback' => 'settings_entity_access',
    'admin ui' => array(
      'path' => 'admin/structure/settings',
      'controller class' => 'EntityOperationsDefaultAdminUIController',
    ),
    'base table' => 'setting',
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    'bundles' => array(
      'generic' => array(
        'label' => t('Generic Setting'),
        'admin' => array(
          'path' => 'admin/structure/settings/generic',
        ),
      ),
    ),


texts:
None of my site aliases defined in /home/peter/.drush/aliases.drushrc.php seems to work. When I ran:

drush sa @mysite.dk.local

I got

$aliases['mysite.dk.local'] = array (
 'uri' => 'mysite.dk',
 'root' => '/usr/share/nginx/www/drupal-7.16/sites/',
 'path-aliases' =>
 array (
   '%dump-dir' => '/usr/share/nginx/www/drupal-7.16/sites/drush.dbdumps',
   '%files' => '/usr/share/nginx/www/drupal-7.16/sites/files',
  ),
);

which looks ok, but when I do

drush @mysite.dk.local status

I get

PHP configuration     :  /etc/php5/cli/php.ini
Drush version         :  4.5
Drush configuration   :
Drush alias files     :  /home/peter/.drush/aliases.drushrc.php

So it seems that drush couldn't find  specified path, cause when I run second command in sites directory everything is showing up as expected. Can anybody point out what I'm missing?


texts: How to disable billing address in Drupal Commerce while using Paypal WPS

texts:
I'm setting up a very simple online shop for a charity. They'll use Paypal WPS and don't want to collect customer's billing address as those will be entered in Paypal anyway. Is there a way to remove the billing address from Drupal Commerce.

I'm only using PayPal, so the aforementioned answer doesn't apply.


texts: How to programmatically publish/unpublished node using flag link and without using Rules?

texts:
I have implemented the functionality on flag link click the content are unpublished and click on unflagging the content are published.
By using the Rules module.

But this time I want to implement same functionality without using rules module and instead using custom coding.

Any suggestions?


texts: Find out module versions through database dump

texts:
I've got a dump from my Drupal database that I've created with Backup and Migrate.

I want to find out which versions of the modules ctools and Panels have been in use.

Where do I have to look? What do I have to search for?


texts: How can i add a property(uuid) to existing custom entity base_table?

texts:
I want to add uuid property to existing custom entity extending ContentEntityBase.
I've tried to a add the uuid entity key and installed field storage definition by:
function my_module_post_update_adduuid() {
  \Drupal::entityTypeManager()->clearCachedDefinitions();
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();

  /** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
  $field_storage_definition = BaseFieldDefinition::create('uuid')
    ->setLabel(new TranslatableMarkup('UUID'))
    ->setReadOnly(TRUE);

  $definition_update_manager->installFieldStorageDefinition('uuid', 'custom_entity_id', 'custom_entity_id', $field_storage_definition);
}

The "problem" is that for custom entity with data_table defined the property is added to the data_table and not to the base_table as expected. If the custom entity doesn't have data table defined the uuid property is written properly in base_table.
Everything seems to work even though the uuid property is defined in data_table but the schema is inconsistent compared to clean install with the uuid key present from the beginning.


texts:
Can't seem to find a similar question, so here goes; I'm writing a module that manipulates commenting on content types; basically, I'm AJAXifying the comments form so it incorprates new comments, new replies and edits (and before anyone asks, I've looked at ajax_comments and it doesn't do what I want).

Basically, on clicking the "Add" comment, I need to be able to set a class on the link element (i.e. "has-form"), and using an ajax callback within the form function thus:

$items['mycomments/newcomment/%node'] = array(
  'delivery callback' => 'ajax_deliver',
  'page callback' => 'mycomments_newcomment',
  'page arguments' => array(2),
  'access callback' => 'node_access',
  'access arguments' => array('view', 2),
  'type' => MENU_CALLBACK,
);

Within the callback function, I need to check whether an element ("#mycommentform") has the class of "has-form" in order to execute ajax_command_* invokes. I know in jQuery I can simply do $("#mycommentform").hasClass("has-form") but how can I do this from within the callback PHP function code?

TIA.


texts:
I have content type Gellery with two fields.
Image (Multiple)
Game Name (Entity Reference)

I am setting Game Name in hook_form_alter. Lets say it is set to "Game 001".
When image is uploaded, it actually resets the form, so the changes made to field "Game Name" donot apply when submit the form.

How to prevent form to be rebuilt on uploading image.
I guess something do to with $form_state

if ($form_id == 'game_gallery_node_form') {
  $form['field_boardgame']['und'][0]['target_id']['#default_value'] = 'game (41)';
}


texts: How to hide a user profile based on custom field?

texts:
I need to allow users to turn off the public display of their profile if they wish too.  I created a Boolean field to store whether the user wanted the profile shown or hidden.  According to this (old!!) documentation on d.o., I should add an if statement at the beginning of the user profile template.

Specifically, is this the proper way to access the value?
Edit: Proper, but must account for possibility that value hasn't been set in existing profiles, thanks!

<?php //check to see that user has chosen to show profile
  if(!isset($field_profile_display) || $field_profile_display[0][value] == 1): ?>

If I put the if statement at the very beginning of user-profile.tpl.php, I see all the fields set to display (with Display Suite), unthemed.  If I put it after , I get a profile page, blank but fo the username as the title.

Where do I put the code to actually prevent the page from displaying?  Does it need to go in page.tpl?

Generally, is this really still the best practice? Would it be better to implement this in a preprocess hook?


texts: Change the order of a sort criteria in views to a custom hierarchy

texts:
I have a content type called Technique that contains a title field, a description field, and a node reference called "belt level" referencing a content type called Curriculum level. The content in Curriculum level are as follows:

Yellow belt
Orange belt
Blue belt
Brown belt
Red belt
Black belt

I have created an Integer field in the Curriculum level content type called level int. I have set "yellow" to 1, "orange" to 2, "blue" to 3, "brown" to 4, "red" to 5, and "black" to 6. Now I have a view of techniques, in which I want the sort criteria to display results based on the level int field value of the content that the node reference field (called "belt level") in the technique was referencing. The problem I am running into is that I have no way of connecting the two. If I use the belt level field to try to set the sort criteria, I can only sort it alphabetically based on the title. How can I sort it based on the level int field instead?


texts: How to redirect to another page after submitting the ctools modal form

texts:
Actually i want to redirect to some other page after submitting the multistep ctools modal form .I have tried using form_state['redirect] and drupal_goto in submit function but didnt work.

function get_quote_menu(){

$items=array();
$items['get_quote'] = array(
  'title' => 'Get Quotation',
  'page callback' => 'get_quote_form',
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
);
$items['get_quote/%ctools_js/details'] = array(
  'title' => 'Get Quotation',
  'page callback' => 'quote_ajax_details_form',
  'page arguments' => array(1),
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
);
return $items;
}
function quote_ajax_details_form($js = NULL, $step = NULL){

if ($js) {

    ctools_include('modal');
    ctools_include('ajax');
 }
  $form_info=array(

    'id' => 'quote_details',
    'path' => "get_quote/" . ($js ? 'ajax' : 'nojs') . "/details/%step",
    'show trail' => TRUE,
    'show back' => TRUE,
    'show cancel' => TRUE,
    'show return' => FALSE,
    'next callback' =>  'get_quote_details_next',
    'finish callback' => 'get_quote_details_finish',
    'cancel callback' => 'get_quote_details_cancel',

    'order' => array(
        'start' => t('View the plans and premiums best suited to you <br/>in 4 straight forward steps.'),
        'second'=>t(''),
    ),

    'forms' => array(
        'start' => array(
            'form id' => 'get_quote_start',
       ),
       'second'=>array(
            'form id'=> 'get_actual_quote_details',
       )
    ),
);

$object_id = 1;

if (empty($step)) {
// We reset the form when $step is NULL because that means they have
// for whatever reason started over.
get_quote_cache_clear($object_id);
$step = 'start';
}

// This automatically gets defaults if there wasn't anything saved.
$object = get_quote_cache_get($object_id);

$form_state = array(
'ajax' => $js,
// Put our object and ID into the form state cache so we can easily find
// it.
'object_id' => $object_id,
'object' => &$object,
);

ctools_include('wizard');
$form = ctools_wizard_multistep_form($form_info, $step, $form_state);
$output = drupal_render($form);

if($js){

$commands=array();

if($output===FALSE  || !empty($form_state['complete'])){

  $commands[] = ajax_command_html('#ctools-sample', finish($form_state['object']));
  $commands[] = ctools_modal_command_dismiss();

}else if(!empty($form_state['cancel'])) {

    $commands[] = ctools_modal_command_dismiss();

}else {

     $commands = ctools_modal_form_render($form_state, $output);
}

 print ajax_render($commands);
 exit;
}else{

 return $output;

 }
}
 function get_quote_start($form, &$form_state){
            $form['first_name'] = array(

'#title' => t('Your Name'),
'#type' => 'textfield',
'#size'=>20,
'#default_value' => $form_state['object']->first_name,
'#attributes'=>array(
    'placeholder'=>t('First Name'),
    'id'=>array('quote-first-name'),
),
//'#required'=>true,
);
$form['middle_name'] = array(
'#type' => 'textfield',
'#default_value' => $form_state['object']->middle_name,
'#size'=>20,
'#attributes'=>array(
    'placeholder'=>t('Middle Name'),
    'id'=>array('quote-middle-name'),
 ),
//'#required'=>true,
);
 return $form;
}
 function get_quote_start_submit(&$form, &$form_state){

global $user;

 $form_state['object']->uid=$user->uid;
}
function get_actual_quote_details($form, &$form_state){
$form['adults']=array(

    '#type'=>'select',
    '#title' => t('Adults'),
    '#options'=>array(
        1=>1,
        2=>2,
        3=>3,
    ),

 );
return $form;
}
function get_actual_quote_details_submit(&$form, &$form_state){

    // Not working redirect
       // drupal_goto('node/add/page');
        $form_state['redirect]='node/add/page',
}


texts: Programmatically displaying a view into a colorbox

texts:
Love the module. My use case is to take programatically take the result of a view and load it into a colorbox. I can use views_get_view or views_embed_view to get a result array or a large html string. But how can I pass that to the colorbox?

Any help is greatly appreciated.

https://drupal.org/node/1991948


texts: Will URLs with spaces in the path work on all major browsers?

texts: Will a path to content such as example.com/content type/page name work? or must it have a filler such as dashes -  example.com/content-type/page-name?


texts: Programmatically insert an image with caption

texts:
I'm trying to attach programmatically an Image with caption to my node.
I'm using image_field_caption module.

    $node = node_load($nid);

    $path = "images/gallery_articolo/".$value['foto'];
    $filetitle = $value['desc'];
    $filename = $value['foto'];

    $file_temp = file_get_contents($path);
    $file_temp = file_save_data($file_temp, 'public://' . $filename, FILE_EXISTS_RENAME);

    $node->field_steps['und'][($value['order'] - 1)] = array(
        'image_field_caption' => array( 'value' => $value['desc'], 'format' => 'full_html'),
        'fid' => $file_temp->fid,
        'filename' => $file_temp->filename,
        'filemime' => $file_temp->filemime,
        'uid' => 1,
        'uri' => $file_temp->uri,
        'status' => 1
    );

    node_save($node);

I followed the stucture seen in devel, but I have a lot of issues..

This is the recent log entry:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'caption' cannot be null:
INSERT INTO {field_image_field_caption_revision} (field_name, entity_type, entity_id, revision_id, bundle, delta, language, caption, caption_format)
VALUES (
:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8), (:db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17);
Array ( [:db_insert_placeholder_0] => field_steps [:db_insert_placeholder_1] => node [:db_insert_placeholder_2] => 455 [:db_insert_placeholder_3] => 863 [:db_insert_placeholder_4] => article [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => und [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => field_steps [:db_insert_placeholder_10] => node [:db_insert_placeholder_11] => 455 [:db_insert_placeholder_12] => 863 [:db_insert_placeholder_13] => article [:db_insert_placeholder_14] => 2 [:db_insert_placeholder_15] => und
[:db_insert_placeholder_16] => Wild Roses: fiori che sembrano appena sbocciati, che sottolineano ancora una volta la sua grande cifra stilistica, composizioni perfette per ogni dolce e speciale occasione.
[:db_insert_placeholder_17] => full_html ) in image_field_caption_field_attach_update() (line 234 of /sites/all/modules/image_field_caption/image_field_caption.module).

But, as you can see, the :db_insert_placeholder_16 is valorized.
Can someone locate where the error is?
I can't find it..

Thank you ^^


texts: Custom Form 'Add More' widget for a field

texts:
This seems like something that should be easy to do but I can find any examples.

When adding a field through the UI you can set the cardinality of the field to unlimited which, given a field type like Number, will give an 'Add More' button underneath the field. This button will pull in another instance of the field via ajax.

Given that you can add this functionality in the UI as part of Core there should surely be away to easily add this in via the Form API?

Could anyone shed some light on this please?


texts: How to handle / cleanup obsolete aggregated css / js?

texts:
I'm only using Drupal 7 built in CSS / JS aggregation, however the files folder where the css.gz and js.gz files live are filling up at a fairly rapid pace, and while I'm sure it'll be a while before it starts to totally fill up the drive, nows as good a time as any to get a handle on the situation.

Current file count in /js is 335
Current file count in /css is 451

Is there any standard method I should be employing to deal with this situation? I'd prefer a solution that keeps the drupal in the loop.

Additionally, I see that many of the gz files have non-gz counterparts. Is there some reason both .css and .css.gz files are kept? Degredation maybe?

Thanks


texts: Display a promo image at last in every slideshow created for a node

texts:
I am using Views Slideshow module to display multiple images uploaded in my article content type.
Every node landing page will have a slideshow displayed with its images (slideshow works fine).
All what I need is one common(Promo)Image to display as the last image/slide in every slideshow.

Is this possible with "Views Slideshow" and "Views" ? Do I need to create a separate tpl file for this?


texts: How to programmatically render a contact form in a theme in D8

texts:
How to get the side-wide contact form (feedback) individually displayed in a custom block or other page then /contact (e.g. frontpage)?

I've tried this code, but it is not working (are contact forms entities?):

// get default form
// get the entity object
$default_form = \Drupal::config('contact.settings')->get('default_form');
$entity = \Drupal::entityManager()->getStorage('contact_form')->load($default_form);

// get view builder
// render view
$view_builder = \Drupal::entityManager()->getViewBuilder('contact_form');
$full_output = $view_builder->view($entity);


texts: How to force initial imported node to not have draft status using feeds?

texts:
I'm using the Feeds (7.x-2.0-alpha9) and the Workflow modules. My imported nodes are automatically going to draft state and only go to done state when there is a second import of this node and the data is updated.

How can I automatically make the state on imported nodes be "saved" not "draft"?

I tried adding a rule upon feeds presave, but it never gets to the save since it is a draft.


texts: Displaying the parent term first in Views

texts:
I have managed to create to organize my content using the Taxonomy module, it is 2 levels deep.

Level 1
    > Level 1-a
        > Level 1-a-i
    > Level 1-b
        > Level 1-b-ii
Level 2
    > Level 2-a
        > Level 2-a-i
Level 3
    > Level 3-a
        > Level 3-a-i

I display this using the Views module.
But the problem I am facing is that the view displays all terms,

Level 1
Level 1-a
Level 1-a-i
Level 1-b
Level 1-b-ii

What I am trying to achieve on this view is something like this

Level 1
Level 2
Level 3

And then when the user clicks a level it will display child, until they reach the deepest level of the taxonomy

Level 1-a
Level 1-b

and then for example selecting Level 1-a

Level 1-a-i
Level 1-a-ii
Level 1-a-iii


texts:
I want to know how to do is create a master or main page. I come from an ASP.Net background and am truly trying to learn Drupal, but I am very frustrated with finding where/how to start.

For me, the start has always been creating a main page. I use .Net as my platform but usually do all my work through HTML and CSS, as in creating a 3-column website using CSS. However, I really like the functionality of .Net in that I create this on ONE page as a master, and then just insert my content in a content holder. I know things don't work exactly the same, I don't expect them to, but I would like to know how to create a master page, or basically a template that contains the header, footer, menus and content layout.

How do I create a basic main page template?


texts:
Is there a way to disable the core Comment module in Drupal 8? The module is enabled by default, but I prefer not to use Drupal comment system and would like to not have it clutter up the GUI for site builders.

I do understand that disabling a module in Drupal 8 is the same as removing it -- perhaps that's why most core modules can't be disabled.


texts: Use webform submission id in custom content type

texts:
I am working on a patient/doctor kind of project where by the patient fills a questionnaire and then the doctor provides a prescription.

I have used webform module to create the questionnaire which the patients would fill, and i have created a custom content type for the prescription.

I need to be able to relate the submission Id of the questionnaire to the prescription but I am not sure how to do it.

Please note that a patient can fill various questionnaires so it is quite important that I use the submission id as it seem as the only unique id available.

I have tried the node reference module but that only gives me access to the questionnaire not submission id of the questionnaire.