texts: How to filter content on a view page using cookies?

texts:
I'm developing a website where users access the content without registration but it still needs to have a favorites system for the elements on the web.
Right now I have implemented a system where i can add items to a "favorites" and the node id for every item is saved on a cookie.
Is there a way to filter the items that are shown by a view page using this node ids saved on the cookies?

I thought that it can be done by altering the query sent by the view or by aplying a filter in some point of the process where i check whether the element returned by the view corresponds with the node id saved in the cookie.

Is any of this options feasible? Is there a simpler way to focus this problem?


texts:
I have created a view in a regular Drupal installation with the commerce modules requiered to run a web shop, so far everything is running smooth. I then create a couple of blocks to present the product information using the Views module in the product display node. All blocks show me the right content when login as admin of the site, but I soon as I logout one of the block content is not shown.

I check the page source code and the block wrap and the table formatter display are rendered, but there is not content as a visitor of the site. What am I missing?

Note: there are not errors log in Drupal watchdog or in Apache or PHP.


texts:
I have a view using one exposed form in a block with a couple exposed filters.  I would like the same result set to be used in two displays that have a slightly different format.

One of my exposed filters is not being "remembered" from one display to the other, even though the other filter fields are.
When I navigate from one display to the other, the problematic exposed filter (a single checkbox) gets rechecked if it was unchecked.
It appears that the query is being re-run when I go from display to display.  I don't really want that to happen since I am using the same result set.  I figured the query only should get run when you hit the SUBMIT button, not change displays.

I have tried to use a number of the hook_views_xxx functions to set and reset my exposed_input array value for the filter field, but I can't seem to get anything to work.  I have also tried using the $_SESSION variable for the field to fix it, but no luck.

If I can understand what is supposed to happen with Views, I can keep trying to solve this myself, but I am really stuck and into this about 10 hours.


texts: db_query() function in a foreach cycle - only the first query is getting executed (D6)

texts:
I have a query, which I have to run in a foreach cycle.
I run the query with db_query() function.
My code looks similar to this one (of course, this is just an example code with example values):

$query = '
    UPDATE mytable SET some_fields = "%s"
    WHERE
    some_fields = "%s"AND
    other_field = "%s" AND
    another_field = "%s"
    ';

foreach($blabla as $index => $value){
    $prev_value = 'these variables are set in the meantime too...';
    $other_field_value = 'blabla';
    $another_field_value = 'blablabla';

    if($this_is_my_condition){
        $query_result = db_query( $query,
            $value,
            $prev_value,
            $other_field_value,
            $another_field_value
        );

        $affected_rows = db_affected_rows();

        if( empty($query_result) or empty($affected_rows) ){
            $unsuccessful_queries[] = 'blablabla '.$index.', '.$value;
        }
    }
}

if(!empty($unsuccessful_queries)){
    $errorMsg = NULL;
    foreach($unsuccessful_queries as $index => $value){
        $errorMsg .= 'Setting '.$value.' parameter was unsuccessful!<br />'."\n";
    }
    throw new ParameterSettingException($errorMsg);
}

In theory, my query is OK, because it works for just one query perfectly with the same values (if it has to be run depending on my condition ( in the example above, $this_is_my_condition ) ), BUT it doesn't work for multiple queries, the rest of the queries are getting simply ignored: my $unsuccessful_queries array is full of the other to-be-updated stuffs that would have to be executed.
The values are correct (that's for sure, because these work with the same values, but with just ONE query!!).

What can be the source of the problem? Why can I run only ONE query, why are the others getting ignored?

Thanks in advance!


texts: How to use views replacement patterns while using the PHP filter?

texts:
In views, when using the standard text formatter you can place replacement tokens such as [title] into the HTML code either in a rewrite or in this case global text for Drupal to render.

In this case I have a node field with the Machine Name field_story_url that is used within a view. Part of my PHP function requires me to define the content found in that field so I do $urlhere= '[field-story-url]';within a Global Text header using the PHP filter input.

But it does not work. I then did a simple <?php echo '[field-story-url]'; ?>to see if it would print the value and nothing either.

When I did the replacement using just HTML it worked. Anyone know what the issue may be?


texts: I have linked my drupal 7 website using xampp with php and hosted on hots gator. Where is the caching of memory happening?And how can i link the database of two sites, both made using drupal?


texts: How can I override Drupal\Component\Datetime\DateTimePlus::createFromArray

texts:
I have to form datelist field. If user select incorrect date, for example 1970-02-31, displayed exception Exception:

  The array contains invalid values. in
  Drupal\Component\Datetime\DateTimePlus::createFromArray() (line 149 of
  core/lib/Drupal/Component/Datetime/DateTimePlus.php).

backtrace:

  Drupal\Component\Datetime\DateTimePlus::createFromArray() called
  at [/var/www/drupal8/core/modules/datetime/datetime.module:802]
  form_type_datelist_value() 2  call_user_func_array() called at
  [/var/www/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php:1542]
  Drupal\Core\Form\FormBuilder->handleInputElement() called at
  [/var/www/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php:1328]
  Drupal\Core\Form\FormBuilder->doBuildForm() called at
  [/var/www/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php:1390]
  Drupal\Core\Form\FormBuilder->doBuildForm() called at
  [/var/www/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php:1390]

I want override exception to return FALSE, and display to user warning about incorrect date.

How do I it?


texts: Can't see resource in Services admin menu after adding hook in the module

texts:
I'm adding Services integration to the room_reservations module. I added the hook to the module like this:
room_reservations.module
function room_reservations_services_resources(){
  $room_service = array(
    'room_reservations'=>array(
      'operations'=>array(
        'retrieve'=>array(
          'help'=>'Gets the hours and the days reservations can be made',
          'file'=>array(
            'type'=>'inc',
            'module'=>'room_reservations',
            'name'=>'room_reservations'
            ),
          'callback'=>'_room_reservations_facility_hours',
          'access arguments'=>array('get reservation hours'),
          'access arguments append'=>FALSE,
          'args'=>array(
            'name'=>'reset',
            'type'=>'string',
            'description'=>'reset',
            'optional'=>TRUE,
            'source'=>'data'
            ),
          ),
        ),
      ),
    );
  return $room_service;
}

Am I doing something wrong? I don't see the custom service.
Also, by reading the docs on the Services module, could this be done as an action? if so how?
Thanks in advance.


texts: How do I access URL parameters from my custom module?

texts:
I have set up a custom page with Panels.

In the Panel configuration I have set the page path to /products/%term.

I made a custom module which currently displays "Hello world" on this page, and all is well.

function product_tree_block_view($delta='') {
  $block = array();
  switch($delta) {
    case 'product_tree' :
      $block['content'] = theme('product_tree', array("greet" => "Hello world",));
      break;
  }
  return $block;
}

However; I would like to process the %term to fetch some additional information, relevant only to the current %term.

My question is: How can I access the %term? Is this variable accessible from my module at all?


texts: Drupal 7, displaying an image to search results

texts:
I have a content type called "people". When a search is made and one of the search results is of "people" type, I want to display two fields of the "people" type; an image called "photo", and a text filed called "email".

Under "Manage Display" of the "people" content type, I selected custom display types and selected "Search Result" box. After saving, I selected the new "Search result" button and hid all other fields except "photo" and "email". I then customized the photo to have image style of "thumbnail".

I saved, cleared the cache, and reindexed the site. The search results are correct but no images are shown. I am very new to Drupal; all the help I could find is for Drupal 6 and by reading the comments people say that the solutions shown do not work for Drupal 7.


texts: How do I render a custom block type (block_content) programmatically with a specific display view?


texts: Drupal7 - Views: Different count of elements per page

texts:
I have an view for displaying 28 contentelements(teaser). (7 rows á 4 elements)
Now there are some elements flagged as "highlighted", so the element size is 2x2 (double width and height), now I want only 25 elements on this page, and the other 3 elements should be displayed on the next page, because of the optic.
How can I do this?
Or an communication with the view, that only 25 elements are rendered, or something like that?

Thanks


texts: How to track which external link users who registered on my site came from

texts:
Google Analytics shows how many and from which links people have visited to my site as I have installed the Google Analytics module. How can I know from which link the individual registered users came from?  For example, I would like to know something like:

  The user (uid:30) came from  http://example.com
  The user (uid:31) came from  http://somesite.com

Or do I have to ask users directly by making a kind of "Where did you know about us" profile field?


texts: How to add pager at the bottom which allow shifting between views?

texts:
I am looking for how to add pager in the complex set of view content.
In my case,
- I have 5 views with different titles, and have 10 items in each views.
- Now, I want to divide each view in 2 pages, so 5 items on each page, so that 5 views will have 10 pages in sum.
- and these all 10 pages has to be connected by single pager 1,2,3....10.
- So on Page-1 View-1 title and its 1stpage and on Page-2 same title and half content of View-1 as described above (5+5).
- and on Page-2 Views-2 with its title and on Page-3 views-2 title and half content of Views-2..
- So, on till views 5. (Please see First image for easy understanding)

Now, what I tried, (1) I added views in views using Views field view module, So I had Main Views which have that 5 views as field and can set 1 item(1 view) per page, so each view will go on each page, but again for dividing each that inside view/sub-view in 2 parts I have to add pager to that each 5 views with 5 items,....So on in the final product MainView(inside Sub-view) will have two pagers....I tried and attaching the Screenshot in the second image.

And Second point, Probably everybody would have seen the Drupal Documentation section of drupal.org. At the bottom the following type of PAGER (shown in attached image- 3) which allow the shift from one topic to other topic. Will it be possible in the above case.


texts:
I have around 400 taxonomy terms; very complicated hierarchical stuff.

I wonder if anyone knows about a plugin (taxonomy manager style) that can help me do it without having to dive into taxonomy and translated one by one.

Thanks !


texts:
How do I change Drupal's default on login url from /user/<uid> to /user/<uid>/edit so that a user gets to there right after they log in?

EDITED:
Tried Rules:

  Events: User has logged in.

  Condition: User has role.

  Actions: Page redirect to user/[current-user:uid]/edit

For some reason it doesn't work.

Tried Login Destination. Redirects work, but the module doesn't support tokens.


texts: Linking to internal pages from the overlay

texts:
I have set up a dashboard to work as a main hub for all things related to my current site. I have quick links to internal pages on my site. I would like to know how I can link to those pages from the overlay without having to setup an absolute url for every link? I'm working on a local instance but will eventually have to push it live so every absolute link will have to change.. and that sucks.

Thanks!


texts: How can I write into a Flag's custom field programmatically?

texts:
I successfully managed to save a flag programmatically in Drupal 8 thanks to this help but I cannot manage to save data into a custom field I added to the flag entity.

The following code saves the flag but the field stay empty.

$entity = \Drupal::entityTypeManager()->getStorage('node')->load($entity_id);
$flag_id = 'bookmark';
$flag_service = \Drupal::service('flag');
$flag = $flag_service->getFlagById($flag_id);

/* Here is where I'm trying to set my custom field value */
$flag->set('field_my_custom_field', $link_name);

$flag_service->flag($flag, $entity);

I cannot find any info into the documentation. Any help will be much appreciated.


texts: SQL error for anonymous users on Views Nivo Slider block

texts:
I have created a slideshow using the Views Nivo Slider module and added it as a block to the home page of my site (running Drupal 6). Everything works great, but for anonymous users I am getting 2 MySQL errors and the block does not display.

You can see the error message by going here: http://staging.thespanishacademy.com

Naturally, I suspect permissions issues but have triple checked everything, flushed all caches, rebuilt node permissions to no avail.

Any help would be appreciated. I'm also including the exact error message below for historical purposes.

warning: Invalid argument supplied for foreach() in /home/spanish/public_html/staging/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 924.

warning: Invalid argument supplied for foreach() in /home/spanish/public_html/staging/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1000.

warning: Invalid argument supplied for foreach() in /home/spanish/public_html/staging/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 924.

user warning: 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 'FROM node node INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant' at line 2 query: db_query /* Anonymous : db_query / SELECT COUNT() FROM (SELECT DISTINCT FROM node node INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid'))) AND ( (node.status = 1) AND (node.type in ('home_page_slideshow')) )) count_alias in /home/spanish/public_html/staging/sites/all/modules/views/plugins/views_plugin_pager.inc on line 141.

user warning: 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 'FROM node node INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant' at line 2 query: db_query_range /* Anonymous : db_query_range */ SELECT DISTINCT FROM node node INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid'))) AND ( (node.status = 1) AND (node.type in ('home_page_slideshow')) ) LIMIT 0, 5 in /home/spanish/public_html/staging/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1150.


texts: Chart & graph as content type? is it possible with any module

texts: I want to create content type as chart and graph, any module which can render my data into chart form ?


texts: How to enable user defined module from the administration menu list?

texts:
I am beginner to Drupal 7. I am trying to start with Basic Form handling. I created a directory my_module in sites/all/modules. Created my_module.info file using notepad with the following contents

name = My module
description = Module for form api tutorial
core = 7.x

Then I created my_module.module file with the following contents

<?php
/**
 * This function defines the URL to the page created etc.
 * See http://api.drupal.org/api/function/hook_menu/6
 */
function my_module_menu() {
  $items = array();
  $items['my_module/form'] = array(
    'title' => 'My form',
    'page callback' => 'my_module_form',
    'access arguments' => array('access content'),
    'description' => 'My form',
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function my_module_form() {

  // This form calls the form builder function via the
  // drupal_get_form() function which takes the name of this form builder
  // function as an argument. It returns the results to display the form.
  return drupal_get_form('my_module_my_form');

}

/**
 * This function is called the "form builder". It builds the form.
 * Notice, it takes one argument, the $form_state
 */
function my_module_my_form($form_state) {

    // This is the first form element. It's a textfield with a label, "Name"
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
  );
  return $form;
}

But when I goes to module list and tries to enable the newly created module  it is not being listed. Kindly help me to resolve this problem.
I have gone through several techniques shown in different forums like deleting multiple copies of the files,providing permissions etc.But all in vain.


texts: How to prevent button to use validation function?

texts:
I have a form with a submit type element and a button type element.

For the form I have a validation and a submit handler functions.

The validation should occur only when I click on the submit type button, but it is also getting used when I click on button type element.

How can I prevent button type element from using the validation function.

P.S.

I have used button type for #ajax.


texts:
i have problem with table width in view.
This is my setup of view:

in my style.css i have this:

.novinky-telo{
width:50px;
background-color:red;
owerflow:hidden;
}

but result is:

I need only 50px width, have you any ideas?


texts: How to add classes to some images in a multi value image field?

texts:
I have content type with a multi value image field. When adding images is it possible to add a class to some of these images? The mark up I'm trying to achieve is some thing like:

So when creating a new node I would like to add 'my-class' to come of the images. I've looked as Field Formatter modules but these seem to add the class on all items in the field.


texts: I have set up a view that shows users a set of nodes for an athletic season that runs September through August.  Each node has a field called Start Date. I would like to filter this start date using the year of the season, i.e. 2012 for the 2012-2013 season.  I've looked into contextual filters but I don't think this is going to work for me, as I don't see a way to provide a range (say 2012-09-01 through 2013-08-31). Will this require a custom module and if so, where can I get some concise instructions on hooking that custom module in with the specific view.  Most of the documentation I read gives a quick code snippet with no specifics on where that snippet is supposed to go.


texts: Apply button hidden on views exposed filter on published content

texts:
I added an exposed filter on Published Content field in my view. It shows the apply button on preview but does not show the submit button in my actual view. Any clues.

Here is the filter in preview

Here is the missing apply button on my view

Thanks.


texts:
I want to create a simple wall, where user can post some text, and other users can reply on it. It can be done without ajax or with. I have made few modules before, but now  i am stack with this part, how to create a page(which i can link into menu) on which i can post message, and then watch the list of this conversations+comments, should i use Views module? any examples would be the way.

here is example of that wall,


texts: Relationship action on custom user profile in custom block

texts:
I have customized the user profile view using panels. All great. Works like a charm. However i am stuck at one point. In the default view there is an option for users to add relationships (using the user relationship module). Now i want that the relationship action, i.e, Follow UserName should appear in my custom block. SO is there any way i can get the relationship action (only the action) to be displayed in a custom block.

Regards

PS: This seemed relevant: http://drupal.org/node/560402 Using this page i tried :

<?php
global $user;
$account = user_load(arg(1));
$actions = _user_relationships_ui_actions_between($user, $account);
if (count($actions)) {
  print theme('item_list', $actions);
}
?>

as well as

<?php
global $user;
$account = user_load($node->uid);
$actions = _user_relationships_ui_actions_between($user, $account);
if (count($actions)) {
  print theme('item_list', $actions);
}
?>

and different other code samples given in http://drupal.org/node/560402...however now when i click on user, it leads me to The White Screen of Death. What am i missing


texts: Taxonomy Menu - Making High-Level Pages Display Something Different To Lowest Level Pages

texts:
I'm fairly new to Drupal so please bear with me if I use dodgy terminology or ask something that seems really stupid!  I have looked through the posts on StackExchange and several other websites but still cannot find an answer to my problem.

I have created a Product Group/Product hierarchy structure in Taxonomy.  It may consist of several level of sub-groups until it gets to the child product.  For example:

Kitchenware

Saucepans

Aluminium
Cast Iron

Frying Pans

Omelette Pans
Woks

Utensils

Using Taxonomy Menu & Views I can get the menu to either:
  (1) Display empty pages for each of the product groups which have no products (i.e. only contain sub-product groups) & then the lowest level product group shows all products that it contains.  So Kitchenware & Frying Pans return empty pages and Woks displays all woks.

or

(2) Each level of the tree shows all of the products in that product group and all of the products in any subordinate groups. For example, Frying Pans will show all products linked to Frying Pans, plus any products in omelette pans and woks.

What I would like is either one of the following:
(1) Not display any page for higher level Product Groups (i.e. make them unselectable) and show product details only on bottom-level groups (e.g. Woks).

OR
(2) Each Product Group shows a list of links to sub-groups that it contains, and then the lowest level group shows details of the products within it.

I have spent many hours trying many different approaches but have not found an answer.  I do not know PHP so I would prefer not to have to try and modify code modules if I can avoid it.

I would be really grateful if someone can help me with this or suggest an alternative approach to what I want to see.

Regards,

Paul


texts: Module for form submitting straight to admin section

texts:
Can anyone recommend a module for a contact form to submit to the administrator (so the administrator can view/read it)?

Users should be able to anonymously submit messages; they should not first log in, or create an account.


texts:
I have a Drupal 6 website that needs to populate a page with data from an XML feed.  We are considering using XSLT to transform the data into an appropriate format, however in searching the internet for ideas I haven't come up with much.

So far I've found CCK XSLT, which doesn't seem to have much documentation behind it, and Services, which seems to interact only with an XML-RPC server (we would simply be pulling a feed itself, not interacting with a server).

Is there a good way to go about doing this?

(Also, I don't have enough rep to create an XSLT tag.  If some kind user would like to retag for me, I'd appreciate it)


texts: Add module-generated pages to Drupal 7's search index

texts:
I have a custom module that provides pages via hook_menu(). The page callback returns HTML-formatted output that is then displayed. The information is fetched from an external database, so it is not a  node/custom content type.

Since the displayed information is somehow the heart of this Drupal site, I want to add the information to Drupal's search index.

How can I facilitate this?


texts: Getting "EntityMetadataWrapperException: Unknown data property" error when I delete a users custom field

texts:
I have added extra fields to the user object.
One of the fields I have added was a Skype text field to hold the user's Skype contact information.
The field had a machine name:
 field_contact_information_skype

Recently we decided to get rid of this field.
After deleting it through the admin UI ( admin/config/people/accounts/fields ) I was no longer able to save a user after editing.
If I did so I would get an error:

  EntityMetadataWrapperException: Unknown data property field_contact_information_skype. in EntityStructureWrapper->getPropertyInfo() (line 354 of /home/master/public_html/sites/all/modules/entity/includes/entity.wrapper.inc).

If I go back and add a new text field to the user object and the text field I am adding has the same machine name then I can edit and save a user object (through the Drupal user edit page) without this error happening.

Should I be able to add fields to the user object and delete those fields without unexpected results like this?
Does anyone know how I can fix this so I can get rid of that Skype field?

Thanks!!!


texts: Render entity from entity reference field

texts: (Drupal 8) So I have a content type called Browse, then I have created a paragraph which is a entity reference field for content of Blog. So now when I create a piece of content in Browser I can add multiple blog posts to this page with the entity reference field from paragraphs. I can not figure out how to render the blog data into my twig template. Maybe I am using the wrong twig template file? I am trying with a field--paragraph--blog.html.twig. Does this need to be done in the theme_preprocessor?


texts:
I've got a field in a panel. I want the field title to be replaced by something that is dependent on another node. In a view this is really straightforward:

View -> Configure Field -> Rewrite Results -> Rewrite the output of this field: ([field_A] is the name of this thing)

The Panel, however, doesn't recognize the [bracket] functionality in Node -> Settings -> Override title.

Apologies if this is obvious, but I can't find the solution anywhere. Any help would be hugely appreciated.


texts: How to set the value of a form with #access = FALSE during validation?

texts:
I have a form element with #access = FALSE.  I'm trying to set the value of this element during form validation using form_set_value().  This works when #access = TRUE, but not when #access = FALSE (although even then the change is showing up in $form_state['values'].  I suspect later on in form processing the default form value is being used instead of the altered value in $form_state['values'].

How can I set this element's value during validation such that the correct value will be passed to the form submit handler(s)?


texts: search only on taxonomy and user autocomplete drupal 7

texts:
I would search only on user and taxonomy in autocomplete but not search in content. I try many modules :

Views Autocomplete
Filters  Search Autocomplete
Custom Search
Term Search

But none complete that ! any clues would be good.


texts: I created my site's homepage using panels(disable blocks regions)and there i placed the user login block. When a user is logged in through the block he is redirected to the homepage while if the user use user/login page he is redirected to his profile. Can i make the login through the block redirect also to the user profile?


texts: Retrieve a list of values from a lookup table using db_select

texts:
I have a "jobs" table where each job can have multiple specialties. So I have a specialties table with a list of all available specialties and I have a lookup table that just has a job_number and a specialty_code in it so each job can be attached to multiple specialties. What I am trying to figure out is when I do a db_select, how can I have the job record print out once, but have a list of it's specialties print out also as part of that record? Here is what I have right now for my query:

$query = db_select("jobs", "j");
$query->fields('j');
$query->join('job_specialties', 'js', 'j.job_number = js.job_number');
$query->join('specialties', 's', 's.specialty_code = js.specialty_code');
$result = $query->distinct()->execute();

This gives me the correct records, but I want to display the list of specialties each job is attached to and that's where I'm not sure how to do that. Is there even a way using the database API to do that?

Essentially I would want to be able to display the records something like this. This is only one record, but you get the idea.

      Job Number
      Title
      Location
      Specialty

    12345
    Some Cool Job
    California
    SQL
HTML5
JavaScript


texts: Form API adds word "edit" in ID of every Form element

texts:
FORM API adds word "edit" before the id of any form element. When I have to use the element in JS  I have to add "edit" before element id.

Example if I have element $form['curdate'] then in drupal_add_js('#edit-curdate');

Why so


texts:
I am using Drupal 8 so there is very little documentation or benchmarks, but I believe a route I have set up for ajax responses is not as performant as it could be.
This is the route:

next_node.ajax:
  path: '/node/{node}'
  defaults:
    _controller: '\Drupal\next_node\Controller\DefaultController::view'
  requirements:
    _permission: 'access content'
    _format: 'json'
    _access: 'TRUE'

And this is the controller:

class DefaultController extends EntityViewController {
  /**
   * {@inheritdoc}
   */
  public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
    $build = parent::view($node);

    return new AjaxResponse(\Drupal::service('renderer')->renderPlain($build));
  }
}

I request the content through this function:

jQuery.get( "/node/2?_format=json", function( data ) { /* Do stuff */ });

Is it normal that it takes about a second on average to get a response? Where to optimize the code?


texts:
Basically i need to create slide show same like this one example.

In this slide show there should be pagination like (1,2,3,4) and i need text and picture should refer to another content type and this text must be taken from the content type(for example the first 100 characters.
How to achive this? what modules is best for this. any example will be nice.
I found some examples with views and slideshow module, but most problem is pagination and how to get the text from content type to show it on a slideshow.


texts: Duplicate migrations listed after generating config for a migrate-upgrade

texts:
TL;DR - I'm trying to build a migration - despite starting from scratch each time, the migrations from my D7 site are duplicated in the drush migrate-status output.

e.g.

d7_node:contact (in the 'default' group)
upgrade_d7_node_contact (in the 'migrate_drupal_7' group)

and sometimes even recursively:

upgrade_upgrade_d7_node_contact

This is repeated for every migration.

Questions:

Firstly, what's going on with the groups? There are no migrations listed under "default" in the UI, but an entire duplicate set when I use drush migrate-status.  What's the default group for in this case? Can I ignore it?
That default group includes a bunch of d6_ migrations. Is that normal when you've generated migrations from a D7 legacy site? None are listed in migrate_drupal_7 or the 'Exporting x as y' output of migrate-upgrade, and obviously many will simply fail with an SQL error because the D6 table structure is different.
As well as resetting the DB before I start (I've verified there are no migrate_plus.migration config entries) and rebuilding the cache (memcached in this case) do I need to be resetting anything else? Does it point to a problem with the source DB?

Specifics:

I'm doing a D7-D8 upgrade, using migrate-upgrade to generate the configuration first so I can then use migrate-manifest to run selected migrations.

As is to be expected, this involves multiple attempts, so I have a clean DB (no content but the correct modules) which I reset to each time:

mysqladmin drop foo
mysqladmin create foo
drush sql:cli < my-clean-d8-db.sql
drush cr

At this stage, /admin/structure/migrate just has an empty Default group.

drush migrate-upgrade --legacy-db-key=migrate --legacy-root=/Users/me/Sites/foo --configure-only

This output of this looks sensible - to use one migration as an example:

Exporting d7_node:contact as upgrade_d7_node_contact


texts: Client-side validation module, fields required only if certain values in other fields are set

texts:
We've built a form using WebForms and are using the Client Side Validation module for AJAX/jQuery validation.

One field on the form needs to only be mandatory if a certain country is selected in the drop down.

We've got as far as being able to customise the styling (the jQuery side of things) to hide/show the required field notice, but we can't seem to dynamically alter the validation rules that the module is working to.

How can we achieve this?


texts:
In Views block, how do I display the articles that only have image?

How to filter it?

Update question:

1） Under Filters, add Content: Image (field_image) - list.

2)  Choose False option.

3)  Preview of block disappear.

How do I fix it?


texts: Display a CCK field on all nodes of a site

texts: How could I programmatically take a CCK field from a particular node and display it on all nodes? The idea is to use the field as an advertisement. So, for example, a content type would have an "ad" field and a checkbox field ("display" or "don't display"). Ideally, the custom module or function would parse all nodes for the checkbox field and then randomly display an ad. Thanks for any advice. It would be for Drupal 6.x, btw.


texts: I have recently inherited a Drupal 7 site on Pantheon.io. None of the admin logins that work flawlessly in the Live environment work in either Test or Dev. I have pushed/pulled code and DB between the three to make sure they are all identical, but the logins still fail in Test and Dev. Any thoughts or suggestions would be greatly appreciated.


texts: Stop views autorefresh from updating the list automatically

texts:
Views autorefresh allows to refresh automatically and update a view. It is working perfectly, but I want to stop it from updating the views automatically.

When there is a new item in the list, it should show a link "Click to view new item". When the user clicks it, the view should be updated with the new items.

Is it possible using views autorefresh?

Note: The view is not a content type, It is showing the list of statuses.


texts: How to correctly configure Fivestar module with a node reference?

texts:
I have a content type "review" with a node reference to "product".
I want to be able to have users rate the product while writing a detailed review.
I added a Fivestar "rating" field in "review" and selected as "voting targed" the "node reference field".
Users can enter the review and rate it at the same time. I created a view to show all the reviews for a product and it pulls the ratings nicely from the "rating" field.

However I can't get a view configured correctly to show an average rating for a product.
I setup a relation with "Content: Vote results", left the "required" box unchecked, "value type" = percent, "vote tag" = "vote", "aggregation function" = "average vote".
All the vote results fields come up empty.

What am I doing wrong?

thank you


texts: Configure Menu Access Visibility and permission

texts:
I have a question for Menu Visibility.  I have an entire live site in production. I am trying to build editorial workflow for my editors, other editors and approvers. I am using Workbench Access and Node Access module.

I wanted to set access permission for menu. Currently, when user create a content, he can chooses menu item from entire "Main Menu section". I don't want them to add any new page in main menu(Home page) as it will ruin my design.

Currently, my menu structure is:

- Main Menu (Home)

About (Parent 1)

Child item
Child Item

Admissions (Parent 2)

Child Item
Child Item

(Parent 3)

Child Item
Child Item

(Parent 4)

Child Item
Child Item

I don't want user to add any content directly in main menu(home page). I want them to just see parent menu items when they create new content and can add them in menu in any parent item or child item. but NOT in Main menu(Home).

I also found two modules but not sure if these are right choice or not.

1) Menu Item Visibility

2) Menu Admin per Role

Thanks!


texts: Can I run the 'Toolbar' and 'Admin Menu' at the same time for different roles?

texts:
I have three extra roles and I would like to use the Toolbar to use the menu for the Editor role, but the Admin Menu for the roles Adminstrator & SuperAdmin. The one problem I run into is that the higher level roles will inherit the permission to also display the Toolbar menu, which is redundant as the Admin Menu is already taking care of.

Thanks for your advice.


texts: override variable in template.php with variable from module_preproccess_node

texts:
I create custom template for node, and put variable in template.php

$colors = array('black', 'white');
$variables['group']['color'] = $colors;
$variables['size'] = 'double';

then i also create module and want to do hook to node template.

mymodule_preproccess_node() {
$colors = array('blue', 'red', 'green');
$variables['group']['color'] = $colors;
$variables['size'] = 'regular';
}

i want to show in my result:

//colors are blue, red, green instead of black, white
foreach ($group['color'] as $color) {
print $color.', ';
}
//and size is regular instead of double
print $size;

am i right? i want to override variables in template.php with variables from my module. then if i disable my module color will back from template.php.


texts: How can I conditionally add a parameterized variable to my themes based on URL?

texts:
I'd like to do something like the following:

If a user goes to node/15, my node.tpl.php file is used, as normal, to generate HTML.

If a user goes to node/15/animal/7, then my node.tpl.php is still used, as expected, but it has a variable in scope called $animal, set to the value that I would get from loading an animal.

So, the URL schema would look something like the following: node/%node/animal/%animal. I want this behavior so that if the user goes to node/15, that's fine, but if they attempt to go to node/15/animal/100 and animal 100 does not exist, the user gets a 404.

The problem I'm running into is that this requires functionality from several distinct areas of Drupal, and I don't know how to make them work together. Adding a custom URL schema would be done in hook_menu(), which requires a page callback. Using anything other than node_page_view would cause the node not to be rendered as normal. BUT, adding a variable to the template's scope would require implementing moduleName_preprocess_hook(), which I only want to conditionally fire when the user hits this specific URL schema.

I could of course manually check the contents of the requested URL myself, perhaps during moduleName_preprocess_hook, but this seems a little too low-level. Surely Drupal has some sort of way to accomodate what I'm trying to do?


texts: Drupal 8 cron not running from external source (as anonymous)

texts:
Running cron with crontab is not working on our Drupal 8 website if the user is anonymous. If I'm logged in as admin, I can run cron with the button or the url with key. If I'm not logged in, cron doesn't run with url with key.

Running from crontab is of course anonymous and so cron is not running.

Any ideas?

Version: Drupal 8 beta 4

Line in crontab:

*/5 * * * * wget -O - -q -t 1 http://www.entityone.be/nl/cron/theactualcronkeyhere


texts: Drush make project versions when there is only dev available?

texts:
Using Drupal 7.x.  If I specify a drupal module project in my make file with no version, for example:

projects[] = geocoder

and the project currently only has a dev version available (e.g. geocoder module as of November 29, 2011):

will make grab the dev version?  Or do I have to explicitly specify the dev version?


texts: Submitting a form rebuilds (expensive) page upon submit

texts:
I have a simple menu callback that draws a page with a form on it. The page callback does a very expensive operation (requests a bunch of data from an external API).

function test_menu() {
  $items = array();
  $items['test'] = array(
    'title' => 'Test',
    'page callback' => 'test_page_handler',
    'access callback' => TRUE,
  );
  return $items;
}

function test_page_handler() {
  $data = very_expensive_data_operation();
  $output = drupal_get_form('test_simple_form', $data);
  return $output;
}

function test_simple_form(&$form_state, $data) {
  $form['create'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

function test_simple_form_submit(&$form, &$form_state) {
  // do something
}

The problem I am seeing is that when the form is submitted, Drupal will re-execute the page callback in the background, resulting in the very_expensive_data_operation() running again.

There are probably lots of great reasons for Drupal to do this, but how can I change my app so that the very_expensive_data_operation() doesn't have to run again when submitting the form (after all, that's why I'm passing $data to the form, rather than having the form run it directly.)

One workaround I can think of is to toss $data into a cache table, but it feels like I'm missing something that available to me in the Drupal+FAPI api.


texts: How to avoid Drush command not found after switching to aegir or other user?

texts:
I installed Drush like this:

It works fine when I am centos user, when I switch user to aegir it doesn't work.

When I do which drush I get:

How can allow user aegir to use Drush?


texts:
I would like to make a content type node title into a Term of reference. The titles need to be limited by some taxonomies.

How to convert Content Type Title into Term reference?


texts: What are the differences between Drush 9 and 10

texts:
We are using Drupal 8.8 with Drush 9.

What are the main risks and benefits of upgrading to Drush 10?

The official release description is rather vague.


texts: How do I filter the user who have logged in once in a view?

texts:
I need to create a view that shows the users who have logged in once to my site.
How can I implement this with Views?


texts: How to tell what module is running from a function call?

texts:
I wrote a piece of shared code, and I am trying to figure out which module is actually calling the specific function. I am looking to have a mode to turn on debug inside of the shared module if it is being called from a particular module. Also this is in Drupal 7.

To call the shared module, I am using the following to call the function, made generic:

module_load_include('inc','rest_api','rest_api');
_rest_api_do_request();


texts: Permissions on example payment method- Drupal commerce

texts: This is probably something simple, but I'm having a hard time configuring the permissions that would only allow the administrators to see the example payment method of the Drupal Commerce module. I have example payment method activated for testing purposes but every time I activate it, the example payment methods appears public. How can I configure the permission so that only the administrators can see the example payment method. I appreciate any help.


texts: I18N site: welcome page with links to translated pages, or translatable content type?

texts:
I need to create a small web site with a single page that has to be translated into multiple languages. My site is I18N, and Locale + Locale updates enabled.

The page manager allows one to create a landing page and set it as the default page. However, I am not really clear how I could automate the translation of that page. I am considering creating a neutral page with links to translated pages. Something tells me this is not the right way to do it in Drupal.

On the other side, I know I could create a "Welcome" content type, with translation attributes/fields. But then, how do I make sure it would be displayed as the landing page with the correct language? Should I create a landing page with one instance of this content type and translate it?

I am still new to i18n in Drupal.


texts: What is the alternative to drupal_realpath()?

texts:
I use drupal_realpath() to do includes for some code samples I have:

 require_once(drupal_realpath('public://php_includes/functions.php'));

This gives the real path C:\www\sites\mysite\files\php_includes\functions.php.
What is the command to get the HTTP path http://mysite.com/sites/files/php_includes/functions.php?

The api documentation says "RealPath is deprecated"... if it's deprecated, what is supposed to replace it to get the same path (either C:\... or http://...)?


texts: Filling form with user entered values after submit

texts: How do I fill a custom form with the values entered from the users before the form was submitted? I have saved the $form_state values, but when I put them back into $form_state on loading, the form fields aren't filled.


texts: How to automatically add http prefix to links in a form?

texts:
I am trying to come up with a solution to fix the D8 Link module to allow URLs like example.com (the most common use case, imho). I was thinking it would be simple enough to modify the submit value during a custom validate function; but regardless of what I set the value to it still validates on the original value.
In a form alter I have done this:
$form['field_linktest']['widget'][0]['#element_validate'][] = '_fix_link_field_value';

and then in that validate function I set the url uri value:
function _fix_link_field_value(&$element, FormStateInterface $form_state, &$complete_form) {
  $url = $form_state->getValue('field_linktest');
  $url[0]['uri'] = 'http://example.com';
  $form_state->setValue('field_linktest', $url);
}

But I still get the error: Manually entered paths should start with one of the following characters: / ? #


texts: Displaying Database Data Within the Flow the Site

texts:
I have a multi-page form that works fine in and of itself (pathfindertool.module). However, once a user clicks submit I want the page to display some records on the page. And it DOES display the records on the page, but NOT within the flow of the page. What I mean by that is, it just puts all the returned results in the top-left of the page in the browser window in  and not in a  tag in the #content area for example where content is supposed to go.

I tried to use javascript document.getelementbyid.innerhtml, calling that from my php and it just returns no results (well it returned them according to console but it didn't display them):

while ($row = $result->fetchAssoc()) {
    echo '';
  }
  }

I also tried doing drupal_add_js inside my .module file and can't get that to work either. Granted my coding here is pretty kloogy:

drupal_add_js('document.getelementbyId("pathfinder-primary-form").innerHTML = "', 'inline');

$title = $row['title'];

drupal_add_js('document.getelementbyId("pathfinder-primary-form").innerHTML = "', 'inline');

Surely this must be one of the most common workflows ever. What's the best practice for displaying data from a database in Drupal so that it displays within a specific  (ie. #main, or perhaps even the form container itself)?

Here's my pretty basic functioning code so far for displaying the results in my .module file:

if ($result) {
while ($row = $result->fetchAssoc()) {
    $title = $row['title'];
    echo '
' . $title. '
';

  }
  }

But of course it displays it in the top-left corner of the body in the browser window right above the Logo! O.O

What am I doing wrong and how can I fix it?


texts: Why is my logo being cached? (Disabling cache for a specific block tpl.php file)

texts:
I have this in my template:

I wrote a preprocess function to override site_logo:

function theme_preprocess_block(&$variables)
{
    if (siteMode() == 1)
    {
        $variables['site_logo'] = '/_logo1.png';
    }
    else {
        $variables['site_logo'] = '/_logoOther.png';
    }
}

However, if I clear cache when siteMode == 1, it shows logo1.png. But then if site_mode changes to 2, it doesn't show logoOther unless I again clear the cache. This leads me to believe it caches the resulting HTML. Which makes sense, I guess, but then how would I be able to do something like the above?

I also tried adding my own Twig Extension and then editing block--system-branding-block.html.twig like this:

{% if get_site_mode() == 1 %}

{% endif %}
{% if get_site_mode() != 1 %}

{% endif %}

This also has the same result. It always shows the one until I clear cache.

Can someone please steer me in the right direction. What should I be using to accomplish what I want? which is to simply switch the logo based on the current mode. Where current mode is determined by a global function called "getSiteMode()".

Any advice?

UPDATE

I tried "set", which worked in html.tpl.php, but not in this template file i am currently working on. This leads me to believe the issue is that I need to disable caching for a specific template?

Anyone know how to do that?


texts: How to remove contents type drupal advanced search page

texts:
When Drupal does a search, and returns no results, an advanced search form is displayed. The form contains a list of content types. There are a couple of content types on our site, but these should be hidden from the user, e.g the end user shouldn't see "contentType", "newType".

I don't want to limit the results, just restrict the user's ability to filter the results using the types.

I've tried looking at the search templates, but couldn't find a reference to the fields.

Any ideas on where I find the correct type or turn off this field?


texts: Pathauto not updating path portion of new path

texts:
When using the following replacement pattern for all nodes (to get 'hackable' urls that respect the menu hierarchy):

[node:menu-link:parents:join-path]/[node:title]

I then create a node with title 'Subnode' which is a child of the node 'Parent node'. This will give me a node with the alias /parent-node/subnode. Now when I move the node one level up and change its (menu)title, so that Subnode is now a 'toplevel' node. The [node:title] part gets changed but the [node:menu-link:parents:join-path] not.

The 'Generate automatic URL alias' checkbox is checked.

Now when choose 'Update URL Alias' from the dropdown list in the content pane (/admin/content) the url does get updated properly.

Why doesn't it get updated right away?


texts: How can I transition an order from fulfillment to completed?

texts:
I'm running Commerce Marketplace and provide store owners a back-end portal for managing their store.
In their portal, they can view orders sitting in the "fulfillment" state with the shipping address.  Once they fulfill that order, I need to provide a button for them to move that order to the "completed" state.
How do I move an order to the "completed" state?  Do I send the user to a specific checkout route, or can I move the order itself to completed via the API?
Currently, the only way to move the order to "completed" is manually in the order under the Commerce administration.


texts: How do you theme the taxonomy description field?

texts:
I need to theme the description field on a taxonomy page. I've tried field--description.tpl.php with no success.

Also, do I also copy the contents of /modules/field/field.tpl.php as a default template?


texts:
I can't figure out how to alter the drupal commerce form. I created a module with a .module and .info file and have enabled 'devel'. I've also enabled this module. However, when I use the following code, or derivations thereof, no message appears in the message area no matter how many times I refresh the page. I've flushed caches and made sure $messages is set to display on the template.

<?php
  function module_name_form_alter(&$form, &$form_state, $form_id) {
    if($form_id == "commerce_checkout_form_checkout") {
      dpm($form_id);
    }
  }

Anyone know what the problem is here?


texts: How to add user picture to created node?

texts:
User image has to be added to created node.
So when user creates node user image has to automatically be added to it.
How it can be accomplished?


texts: How do I limit validation errors to submission buttons?

texts:
Using hook_form_alter I have tried to add limit validation errors to workflow submission button.

In form alter I'm getting two form_id's one is normal node add form_id and
another is workflow state form_id.

$form['actions']['workflow_course_status_save_as_draft']['#limit_validation_errors'] > = array(array('field_sample_course'));


texts: If linking entities with a multi-value entity reference field, what about properties of the association?

texts:
In this thread I need a link from base table to join table
it was suggested that it is better in Drupal to join two entities with a multi-value entity reference field than to use a relational style join table to join them (assuming many to many relationship).  But, what about the case where there is a property of the association.  E.g., stories win awards, but each award is or may be granted every year.  So, in a relational design, one would use a join table to link a particular story with the award it had won and put the year into the association.  What is the Drupal Way to do this with a multi-value entity reference field?

OK, here is a simplified diagram of the relationship between Story and Award showing the property on the association.


texts: Unable to add images to content "Image field is required"

texts:
Developing a new site with Drupal 8, I was attempting to add an image to a custom block. In the editor I clicked the image icon and got a dialog to upload an image. After specifying a file (making sure it was within the upload file size), I got a strange error "Image field is required."

I took the error message literally, and created a new custom block type, adding a field of type "image" to the block. So now in the form, I have a Body and an Image field. If I try to upload using the "image" field below the body, I get the same error "Image field is required."

I tried again using the Content / Media tab, to add an image file, and get the same error:

(I also notice that there's a "Caption" checkbox but no field to enter a caption. I'm assuming I'll have a text field once the image is uploaded.)

Drupal 8.8, all current.


texts: Removing a field from the new content form

texts:
I have created a content type which consists of a title a .zip file and a screenshot using Drupal 7's site builder.

When a user adds an instance of this content type I would like for them to only have exposed fields for the .zip file and the title.  I have a custom module that unzips the .zip file and does some analysis and I would like to extract the screenshot at this time.

Is there anyway that I can have the new content form of my content type not show the screenshot field?


texts:
If I wanted to rebuild a form in Drupal 7, conditional on the state of the form, I would do something like this:

if (isset($form_state['values']['foo'])) {
  $form['...
}

Now, $form_state is an object in Drupal 8. What would be the best equivalent?


texts: Trying to alter SKU field on ubercart product that is also a course

texts:
I'm trying to modify a course (from the course module) and a product (from ubercart). I want to remove the SKU (right now I'm just testing how to remove the required bit) and a few other fields as I'm selling only online products. I'm not great at using hook_form_alter() yet.

I'm trying to follow this tutorial, http://www.ubercart.org/comment/8749/Re-Removing-SKU-product-edit-page and I'm not quite sure where he is getting $form_id == 'product_node_form' - is that related to the content type?

I'm trying to do this on a course content type, so if so, that would explain why it isn't working for me.


texts:
When I am inserting a new article there is an error -

  Notice: Undefined property: stdClass::$field_tags in
  hook_node_presave() (line 344 of
  D:\wamp\www...)

The code for line 344 is-

function mltag_node_presave($node) {
...
$count = count($node->field_tags[$node->language]); //line 344
..
}

This error only shows up when adding a new article, and not when editing an article.
The line 344 is just to count the number of term-ids in the textfield for tags.
Any suggestions ??

EDIT - field_tags is the name of the default Tag textfield added in the add-article page


texts: Specific field tag based naming conventions (overriding views-view-field.html.twig for specific fields)

texts:
I've scoured the documentation and I simply cannot find an answer to this question regarding naming convention for twig files given a tagged view with the override of a specific field.
Let me create a scenario to explain the problem.

Given Viewname with tag viewtag with a block display and a fieldname field.

I can override the theme as follows

Original file --> Overridden file name

views-view-unformatted.html.twig --> views-view-unformatted--viewtag.html.twig
views-view-field.html.twig --> views-view-field--fieldname.html.twig
views-view-field.html.twig --> views-view-field--viewname--block--fieldname.html.twig
views-view-field.html.twig --> views-view-field--block--fieldname.html.twig

I cannot figure out how to override views-view-field for a specific fieldname by specifying the viewtag. The following names do not work:

views-view-field--viewtag--fieldname
views-view-field--viewtag--block--fieldname
views-view-field--fieldname--viewtag
views-view-field--block--fieldname--viewtag
views-view-field--block--viewtag--fieldname

I've run out of possible combinations and yet I'm simply not able to get the viewtags to override the specific field. Surely there has to be a way to do this given that you can use the viewname to override the templates. I'd rather avoid having 50 versions of a view template when 1 could do the same thing.


texts: Create a view with mix of content and files

texts:
Is there a way to create a view that will allow showing listing of two entity types, for example combine items from the Content and File Entity Files views?

Lets say we wish to show a listing of all content belonging to a user. We create a view for Content entity, then add user as a required relationship, but this does not show the file fields to be added to the view.


texts:
TAC is installed (Taxonomy Access Control). There's a taxonomy vocabulary called "TAC Roles" that determines which users can view which content. In this vocabulary are two roles: "trusted user" and "exclusive access user". There are also roles with the same name.

Now the thing I want is that users can only see the content if they have all the roles associated with the TAC Roles vocabulary. I.e.: if a piece of content has both terms selected only users that have both roles should be able to see this node.

TAC is now set up that authenticated users are denied both Exclusive Access as Trusted access. The trusted user has Exclusive Access on Denied but Trusted access on Allow. The Exclusive Access user has Exclusive Access on Allow but Trusted access on Denied.

The problem I have now is that if a user has both roles and a piece of content has both terms associated the node will not be visible to this user.


texts:
I'm trying to check if a date field value has been changed on a node update. (Rules Drupal 7)

Here's my rule configuration:

    { "rules_node_update" : {
    "LABEL" : "Update",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave--expedient" : { "bundle" : "expedient" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node-unchanged" ], "field" : "field_tria" } },
      { "NOT data_is" : {
          "data" : [ "node-unchanged:field-tria" ],
          "value" : [ "node:field-tria" ]
        }
      }
    ],
    "DO" : [ { "drupal_message" : { "message" : "UPDATED DATE" } } ]
  }
}

Event: Before saving (i have already tried with node update)

NOT data comparison
Parameter: Data to compare: [node:field-tria], Data value: [node-unchanged:field-tria]

What i'am trying to do here is... IF the (new) date value IS NOT EQUAL to unchanged field value (old)... THEN do something. (like print message on screen)

The result of the data comparison returns always TRUE and don't know why.

Notes:

Having proven the suggested changes, the result remains the same. I edit a node, and whether I change the value of the "tria" field or not, it still returns true.
If I (temporary) OMIT the data comparison it shows the final message. Here's an example of what i'm getting with my setup: Edit a node of this content type, the node already has a date data in the "tria" field. Without making any changes, just save. It shows the message. If i change that field value to another and then save. It also shows the message. So, i think node-unchanged value must me empty because she's not doing the data comparison the right way.
Here is the debug of the variables after saving/updating a content : Debug value Parameter: Value to debug: [node-unchanged:field-tria] ... (Array, 1 element) 0 (Array, 6 elements) value (String, 19 characters ) 2001-01-10 01:00:00 value2 (String, 19 characters ) 2001-01-10 01:00:00 Debug value Parameter: Value to debug: [node:field-tria] ... (Array, 1 element) 0 (Array, 10 elements) value (String, 19 characters ) 2001-01-20 01:00:00 value2 (String, 19 characters ) 2001-01-20 01:00:00 Values are there, and they are different! as expected!
The rule evaluation log shows this once the node has been updated with different values:

The rule evaluation log shows this once the node has been updated with no changes on the values... just saved


texts: Can custom module function names contain characters between 7F and FF?

texts:
PHP defines valid function names as [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.

I have already been bitten by Drupal name conflicts when using hook_form_alter clashing with my module name when it contained common words separated by an underscore "_" ("isys_helper_form_alter").

So I thought about using the broken pipe character instead like I have done in other PHP projects ("¦", char #A6, "isys¦helper_form_alter").

Unfortunately, Drupal does not seem to find any functions I name using characters in the 7F to FF range.

Is this a documented difference with Drupal vs. PHP?

Searching the documentation online did not state any such difference, but I could have missed it.


texts: Can't moderate content from "View Draft" page using Workbench Moderation

texts:
I am using Panels Everywhere, and Workbench Access & Moderation.
I have gotten everything to work, but I haven't been able to figure out how to get the block above the content created, that allows the moderator to go from Draft > Needs Review (or another transition).

9:24 in at http://nodeone.se/node/1024

I can moderate the content from root/node/#/moderation, but can't on the webpage.

Seeing if someone has run into this before and can help me out.


texts: Extending EntityFieldQuery. Which variables should I define?

texts:
I have been playing around with extending EntityFieldQuery, and I was wondering which variables I should define on the class. I am also a beginner in OOP so this is an experiment.

class nodematcher extends EntityFieldQuery
 {
  private $pathtomatch = NULL;
  private $nodestocheck = array();
  private $matchingnode = NULL;
  private $query = NULL;
  private $results = NULL;
  public $nodes = NULL;
  public $path = NULL;
  public $json = NULL;
  public function __construct()
   {
    $this->query = New entityFieldQuery;
    $this->query->entityCondition('entity_type', 'node')->fieldCondition('geoslate_slate_entry_path', 'value', '', '<>');
    $this->results = $this->query->execute();
    foreach($this->results['node'] as $result)
     {
      $this->nodestocheck[] = $result->nid;
     }
    $this->nodes = entity_load('node', $this->nodestocheck);
    return $this->nodes;
   }
  public function lookupfullpath($path)
   {
    foreach($this->nodes as $key => $value)
     {
      $wrapper = entity_metadata_wrapper('node', $value);
      $entry_path = $wrapper->geoslate_slate_entry_path->value();
      if(reset($entry_path) == $path)
       {
        $this->matchingnode[] = $wrapper->nid->value();
       }
     }
    $loadedentities = entity_load('node', $this->matchingnode);
    //$this->json = drupal_json_encode($loadedentities);
    return $loadedentities;
   }
 }


texts: How do I remove the Title "Languages" from the Language Icon Module?

texts:
I am trying to create a bilingual site from a Drupal 7 site that already exists in English. I have absolutely no programming background, yet have managed to make it quite far thanks to reading other individuals' questions and answers on Drupal Answers. Thanks guys!

Now I have some questions of my own :) For these questions the page I am referring to is http://laidea.us/testingpage

I would like to remove the title "Languages" or "Idiomas" (in Spanish) from the Language Switcher block. I tried seeing if I could do that in views, but couldn't find the Language Switcher block there.
I would like to have my language icons be side by side, and without the list bullets next to them.
I've noticed that it says what language the content is in, and there is a language switch below my text. How do I get rid of/ hide these fields?

Thank you for your help!

-Jane


texts: Aggregating but not taking the first result

texts:
I have a set of profiles, and some users have two of the same type.

Well one of the views gets around these duplicate profiles by aggregating them. The problem is that it grabs the first of the two duplicates.

Provided that programmatically removing the extra member profiles isn't really feasible, is there a way to grab the second of the two duplicates?

A sample of the query is here:

select DISTINCT p.pid, p.type, p.uid, u.name from profile as p
join users as u on (u.uid = p.uid)
where p.type = "member"
group by u.uid
order by p.uid, p.pid DESC


texts:
I am currently searching for a example to migrate data into an address field in Drupal 8 without any luck for now.

Has someone a hint for me on how to map the fields?

I tried the following:

my.migrate.yml file:

'field_date_address/address_line1': date_tmp_address_address_line1
'field_date_address/locality': date_tmp_address_locality
'field_date_address/postal_code': date_tmp_address_postal_code

Callback:

$row->setSourceProperty('date_tmp_address_address_line1', 'Teststreet 18');
$row->setSourceProperty('date_tmp_address_locality', 'Test locallity');
$row->setSourceProperty('date_tmp_address_postal_code', '12345');


texts: How to remove the word "New" for the new comments

texts:
When I add a new comment, the word "New" is printed at the top:

I don't need it. This word can be removed by editing the file /modules/comment/comment.tpl.php:
//remove these 3 lines, and the word will disappear
<?php if ($new): ?>
  <?php print $new ?>
<?php endif; ?>

But I don't think, that changing core modules is a good idea.
How can I remove the word without changing the core files?


texts: How to launch a Rule when X nodes were created in X days time?

texts:
I'm currently awarding medals to the users on my website by using the Goals and Rules modules: a medal awarding Rule fires when a Goal is completed. However, I'd like to get rid of the Goals module, because it is no longer maintained at the time of writing and it doesn't fully provide the functionalities that I need.

The Goals module has a nice feature, though: it is possible to record tasks that were completed within a certain period. I would like to keep this functionality, because some of my medals are granted to users who created X nodes in X days time.

Therefore, I had the idea to add a condition to my medal awarding Rules that checks whether the user created, say, 5 nodes in 10 days time. Is it possible to do this?


texts: Add CCK field to panel / page (from page manager)

texts: Working in a D6 site, I was asked to add the CCK field that appears in all nodes, which is a taxonomy term reference, a tag, to a "Landing Page" created using page manager and panels. Is that even possible? If yes, how would I go about doing that?


texts: Can an AJAX form request replace elements of different types?

texts:
I'm trying to write an AJAX form in Drupal 8. I managed to get a simple example working yesterday, but today, my work fails without error. I was wondering whether anyone here could spot my error.

Here are the relevant excerpts from my OverviewForm:

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

  ...

  $form['job_id'] = [
    '#weight' => 1,
    '#title' => 'Job',
    '#type' => 'select',
    '#options' => $formatted_jobs,
    '#ajax' => [
      'callback' => '::showFiles',
      'event' => 'change',
      'wrappper' => 'jobfiles'
    ]
  ];

  $form['jobfiles'] = [
    '#weight' => 2,
    '#title' => 'Files',
    '#type' => 'html_tag',
    '#tag' => 'span',
    '#value' => 'Please make a selection above',
    '#attributes' => [
      'id' => ['jobfiles']
    ]
  ];

  return $form;
}

public function showFiles(array &$form, FormStateInterface $form_state) {
  $job_id = $form_state->getValue('job_id');
  $elem = [
    '#weight' => 2,
    '#type' => 'item_list',
    '#items' => $this->_files($job_id),
    '#attributes' => [
      'id' => ['jobfiles']
    ]
  ];

  return $elem;
}

The list of jobs populates correctly, but when I select one, the initial jobfiles span isn't replaced with anything. I'd expect it to at least disappear when I select a value from the select. Thanks in advance!


texts: views 3, show exposed filter - User: name, as list instead of autocomplete text field

texts:
Drupal 7 Views 3, Is this possible and how

The default exposed filter form for filtering by user name shows up as a textfield in which the user types the username by which to filter and a nice autocomplete

I want this to be a jump menu or list with check boxes instead so the user can see al the names listed and choose from that list (like the taxonomy list)


texts: views slideshow force al link to basic page instead of the slideshow's custom made url

texts:
I am using Views Slideshow for my front page and I want the url output of the image to go to a basic page but there is a conflict because the slideshow creates a page with that image and it makes it a different page than the one it should point to.
Example: I have a slideshow image that should point to the about-us page but when creating the about us image slide it creates a new url...so I end up with one about-us page and the slideshow image points to /node/23.

I tried the image link formatter module, created the proper field in Slideshow (Content type) field_image_custom_link and linked the image to this field. And in views I set a rewrite result to output the field as a link and put [field_image_custom_link] and it will simply send the image to the url: /field_image_custom_link#overlay-context=!
Any help would be appreciated, I just want the slides to point to specific existing pages! :)


texts:
i have a problem and the documentation of drupalgap is not too specific.
I have a site for example "www.mysite.com" and i have in a localhost a site built in drupalgap that i want to connect with "www.mysite.com" and the drupalgap app shows the content of the database stored in mysite. It's possible to achieve that? I installed the services module and configured it but i don't know how to proceed. Any help will be appreciated. Thank you.


texts: Can I use 'drupal_add_library' inside an ajax call?

texts:
The title is pretty self-explanatory, I would like to do something like this to display a jQuery UI dialog:

function my_ajax_page_callback() {
  drupal_add_library('system', 'ui.dialog');
  drupal_add_js('jQuery.dialog(...)','inline');
}

Specifically, I would like to include the library on-demand, not on every non-ajax request. Is that possible in D7?


texts:
I've updated my LOCAL site with composer, updated the database but can't access the Status Report page (site encountered an unexpected error). I looked at the recent log messages and saw this error:

  Location  http://i.l/admin/reports/status

  Message   Drupal\Component\Plugin\Exception\PluginNotFoundException: The
  "phpmailer" plugin does not exist. in
  Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of
  /home/www/mySite/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

How can I resolve this issue?


texts: During checkout, why is the customer skipping the payment step?

texts:
I have a situation during the checkout process where the customer is skipping the payment and moved directly to the fulfillment state.  I'm using the Commerce PayPal module.
Here's my checkout flow: /admin/commerce/config/checkout-flows/manage/default

What's odd is the PayPal buttons display when I'm logged in as Admin, but not when non-admin:

I haven't found an option that looks relevant on the permissions screen, nor have I found a configuration option anywhere.
The order type is configured to use the correct checkout flow (Default).


texts: How can I add a property definition to an existing field?

texts:
I have a file reference field FileItem that has a display and description property but I want to add an extra one.

I was hoping I could just override the default widget but I can't use this to store data.

My next hope was to override the FileItem class and define the new property in schema() and propertyDefinitions() but that would mean I need a new FieldType.

I don't really want to create a new FieldType as I would need to migrate all of the data from the existing field.


texts:
EDIT:

14:38 PM Amsterdam :P

Nice to see that good people help !...

What I trying to do:

This is the whole prototype code.

function oleg_menu() {

    $items=array();
    $items['user/%user/pgacademy/tests'] = array(
        'title' => 'OLEG',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('oleg_nameform',1),
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function oleg_nameform($form, &$form_state,$accoundID) {
     $form=array();
     dpm($accauntID);
     return $form;
}

The page even doesn't appear...
Can someone explain me why it fails,or what could be the problem ?
Oleg


texts:
I need a headless web browser with JS support to use during cron. It seems like the simpletest module does what I need, but how could one initiate a browser and hand it a DOM?

Outside the context of Drupal cron, it would go like this:

require_once('simpletest/browser.php');

$browser = &new SimpleBrowser();
$browser->get('http://php.net/');

But, is there a way I can use the code that the simpletest module already provides?


texts:
So i have set up a page view which has the path about/% with % representing the argument used in that view. I now want to link to this page on the main navigation bar.

I created a menu item  about/%dest but that didnt work as i guess the route is already registered by the view? so i altered it to look like this:

$items['%dest/about']= array(
  'page callback' => '_bps_path_redirect',
  'page_arguments' => 'about',
  'title' => 'about',
  'title callback' => 'get_title',
  'access arguments' => array('access content'),
  'type' => MENU_NORMAL_ITEM,
  'menu_name' => 'main-menu',
);

function dest_to_arg() {
  $arg = arg(1);
  return $arg;
}

function _bps_path_redirect($arg) {
  drupal_goto($arg.'/'.arg(1));
}

But to no success, the redirect doesn't work. So am i missing something? Is there a simple way to link a view which has a wildcard in its path?


texts: How do I store large volumes or data points using Drupal ( temperature and humidity points )

texts: I'm trying to use Drupal as a headless API, and so far I'm having good results. One of the things I'm collecting is a Temperature and Humidity data. Thus far I've created an entity that can hold the data points, but now that I'm really thinking about it, this is not the most efficient way of doing this, a new entity has to be created for each datapoint. I've contemplated separating off this part of the api, but then I loose all of the Drupal functionality. Is there a better way to store large sets of data points using Drupal? Perhaps I can group the data points within a single field as a JSON string? I'm using D7


texts: Unable to set field collection field value on form validation

texts:
The question might look similar to How to form_alter fields attached to an unlimited field collection? but I am more concerned about "values not saved after custom validation"

I have a field collection "field_assignments" consists of:

field_check_user: A user reference field
field_assigned_booklets: An integer field
field_total_cost: A hidden field (used in validation handler for calculation)

I have content type "marking" having this field collection (unlimited values) along with a field_rate. I have alter node editing form and defined a custom validation which is working fine. The problem is that I cannot update the field collection item "field_total_cost" value in custom validation function. The validation function is

function _additional_validate($form, &$form_state) {
   // If rate is set to 100 and assigned booklets are 5; this should result 500
   $tc = $form_state['values']['field_assignments']['und'][0]
         ['field_assigned_booklets']['und'][0]['value'] * $form_state['values']['field_rate']['und'][0]['value'];

   $form_state['values']['field_assignments']['und'][0]['field_total_cost']['und'][0]['value'] = $tc;
}

If I dpm $form_state, I can see that the ['field_total_cost']['und'][0]['value'] is updated (see image below) but when the node is submitted, it does not show that value in node view and does not save that value in the database. How can I save a value in field collection field?

I tried form_set_value() but couldn't understand how to set value for compounded fields (field collection in this case, I'll be thankful if someone can show how can I construct that "#parent" stuff with these fields). The code with form_set_value() I tried:

 // testing on a single field - works perfectly
 form_set_value($form['field_rate']['und'][0]['value'], $tc, $form_state);

 // does not update the value
 form_set_value($form['field_assignments']['und'][0]['field_total_cost']['und'][0]['value'], $tc, $form_state);

P.S: I have written 'und' instead LANGUAGE_NONE for ease


texts: Drush 9 on Windows 10 -- some Drush scripts not found -- but other Drush commands work

texts:
My environment: UniServerZ XIII (a form of WAMP server), Drupal 8.4.3, Drush 9.x, Windows 10 Pro. Used Composer to install Drupal and also for Drush (as a site install). Windows PATH (for local user) settings include for Composer, MySQL, and Drush (at vendor/drush/drush from the Drupal project root). Bash is running thru MINGW64 (from Git for Windows).

[An aside: for those who find Drush throwing a bootstrap error, even though other Drush commands (such as core-status) work, what solved that one for me was adding MySQL to the Windows PATH.]

So Drush is 90% or more there for me.

What I need is to find is the configuration setting that sets the path/to/drush/script.

I've checked everywhere I can think of -- the config files in my  folder and, in the Drupal project, the "vendor/bin" folder and the "vendor/drush/drush" folder and some of the latter's subfolders [why are two folders needed for Drush in a site install?].

When I run "core-status", the relevant line says this:

  Drush script     : C:/[path to Drupal project root]/vendor/drush/drush/drush

which file does exist, but (I'm guessing) isn't an effective command file in a Windows context.

Because: when I run "entup", the command returns a success code overall, but not before spitting out two error messages saying this:

  [error]  The command could not be executed successfully (returned:
  '[path to Drupal project root]/vendor/drush/drush/drush' is
  not recognized as an internal or external command, operable program or batch >file., code: 1)

I'm hoping that if I can find that config setting, I'll point the Drush script parameter to either "drush.php" or "dr.bat" instead of the "drush" file and that will fix what I hope is a last set-up problem in Drush on Windows 10. (The "drush" file itself seems to call drush.php.)


texts: Why can only admin user access the print version of a view?

texts:
I have installed the Printer, email and PDF versions module and I have a view named XXX and the admin can access to the print version of the XXX view with the path /printpdf/XXX.
If I change the user to other user without admin permission, I get this message

Access denied
You are not authorized to access this page.

I don't know how to allow non admin users to access the print version of a view.
I set this permissions for non admin users like so:

Bypass views access control.
Access the printer-friendly page.

But such user still does not have access to the print version of a view.
Is there a way to achieve the access with non admin users?


texts: Need some advice on implementing a HDFS file storage solution for drupal

texts:
We are looking into using HDFS to store our files users upload through the drupal Site. I have not been able to find a module that claims to do this already so we thought we would build one. So my question is 2 folds.

Is anyone aware of a module that could do this?
Is there a specific API standard to build this out of drupal? Is it just a matter of implementing a  HDFSStreamWrapper

Thanks


texts: Using Views Arguments, how do I hide the view results with less than N number of total rows?

texts:
I'm using Drupal 7, Views and Flags to display nodes flagged by a user. I want to be able to hide the results, or use and alternate view display, if the view contains less than N number of results, Let's say 5.

So far I've tried using PHP code to validate my contextual filter:

Contextual filter: Flags:uid
Specify validation code: PHP Code

if ($view->total_rows > 5) {
return TRUE;
} else {
  return FALSE;
}

Can anyone tell me where I'm going wrong here?


texts: CSS and JS 404 On Admin Site Only - New Install

texts:
This is a new server build...

me@server:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

Apache...

me@server:~$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2019-09-16T12:58:48

I downloaded the Drupal 8.7.8 tar.gz and installed using the Standard installation profile into an Apache VirtualHost.  The visitor portion of the site displays and functions as expected, however the admin portion has issues.  The main page, /admin, displays styled.  However, clicking on the various links, Content, Structure, Appearance, etc, result in a page with no style.  Inspect's Network tab shows...

http://my.server/admin/sites/default/files/css/css_<snip-long-random-string>.css?0
...
http://my.server/admin/core/assets/vendor/modernizr/modernizr.min.js?v=3.3.1
http://my.server/admin/sites/default/files/js/js_<snip-long-random-string>.js
...

Still in Inspect on the Network tab, the CSS files show a Status of "(cancelled)" and the JS files are all 404.

Maybe I have something wrong with URL rewriting.  During installation in the "Requirements review" I received the warning about clean URLs - the server is capable but not enabled.  Well, mod_rewrite is enabled and I have the following in my VirtualHost config...

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

With setting RewriteEngine off the visitor site only partially works.  For example, the contact form is 404 while search works but has no CSS.

All other prerequisites passed.

I removed the whole Drupal filesystem and dropped the database.  Another new installation yields the same results.  Further suggesting that this is an Apache config issue.

Your time and help in resolving this is appreciated, thank you.

== Edit ==
The more I investigate the more I feel this is rewrite related.  I moved all of the Rewrite statements into the top <Directory> and the site, visitor and admin, is 100% broken and I now receive the following in Apache's error log...

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
AH00121: r->uri = /index.php
AH00122: redirected from r->uri = /index.php

The last entry is repeated a number of times.  I have LogLevel debug.

I understand the result but I'm not sure what the Rewrite statements should be and where they belong.  My [current] vhost...

<VirtualHost *:80>
    ServerName [redacted]
    DocumentRoot /var/www/html/test
    <Directory /var/www/html/test>
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteOptions inherit
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    </Directory>
</VirtualHost>


texts: Search results: order & group by custom field

texts:
I customized the display of my search results so I can show custom fields in the search results (other question).

I have a custom field ('Department'). I want to show the search results grouped and ordered by that field.


texts: How do I build a dynamic query in Drupal 7 equivalent to this SQL query?

texts:
I want to make this SQL query into a dynamic drupal query:

SELECT name, u.uid, COUNT( n.nid ) AS total_written
FROM users u
LEFT JOIN node n ON n.uid = u.uid
GROUP BY u.uid
ORDER BY total_written DESC

I do not know where i should append the COUNT. This is what I tried:

$query = db_select('users', 'u');
$query->leftJoin('node', 'n', 'n.uid = u.uid');
$query
  ->fields('u', array('uid', 'name',))
  ->fields('u', array('COUNT(n.nid)', 'total_written')) # Wrong
  ->groupBy('u.uid')
  ->orderBy('total_written', 'DESC');

How do I append the COUNT to the dynamic query?


texts: How to serve 404s for non existent views paths with facets

texts:
Is it possible have non-existent views paths 404, but to allow facets and parameter searches?

Most of the answers to this question for base views, are either for Drupal 6, or use Mikeytown's excellent Views404 module.

However this isn't an option if you're using faceted search. Using Views404 will return 404s for all of your faceted pages.

Is there a general way to catch when views isn't hitting a facet or an allowed parameter?


texts: Looking for multi step form in Drupal that can also show submissions in Admin

texts:
I hope I am not offending someone with this naive question.

I am currently trying to create a customized JQuery + PHP + HTML multi step form in Drupal. I am hoping if anyone of you could let me know if there is some way I can create this and also see the submissions through Admin.

Many Thanks.


texts:
Right now, I am using JQUERY UPDATE module, 7.X-3.0-alpha2 version. The default version is 2.1. However, I have some trouble when I edit my product which is a reference field.

If I enable this module, when I try to edit my product, I will receive some AJAX error message.

If I disable this module, I cannot even add an existing product to content type. After I click the "add existing product" button, nothing will happen.

Edit:
My default version is 1.8 now, but still doesn't work. I also tried 1.7 version.

Also got this error:

I have two questions:

after I configure the module, do I need to clear the cache or do some other thing?
According to my new edit, is that the correct place to change the jQuery version?

Note: It used to work before. There is no new error in console. But I got some "GET XXXX net::ERR_CONNECTION_TIMED_OUT"


texts: Use Filename for File entity Page and Window title

texts:
Drupal 8 file entity full display mode apparently uses the word 'File' for both page title and window title.  Yuck.

I've reviewed the various answers on this question, but I'm not seeing a definitive or ideal answer to this specific case. I do have a working solution based on a few answers there, but I don't like it so much. (It's very possible I've overlooked some key bit of insight from that post).

/**
 * Implements hook_page_attachments_alter().
 *
 * @see mymodule_file_view_alter()
 */
function mymodule_page_attachments_alter(array &$page) {

  // Use the file name as the window title.
  if ($entity = \Drupal::routeMatch()->getParameter('file')) {
    $title = $entity->getFilename() . ' | ' . \Drupal::config('system.site')->get('name');
    $page['#attached']['html_head'][] = [
      [
        '#tag' => 'title',
        '#value' => $title,
      ],
      'title'
    ];
  }
}

/**
 * Implements hook_ENTITY_TYPE_view_alter().
 *
 * @see mymodule_page_attachments_alter()
 */
function mymodule_file_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
  // Use the file name as the page title.
  $build['#title'] = $entity->getFilename();
}

I would love to be shown that there is a way to both alter the window title and the page title cleanly from one single piece of code, without for example, getting into the yuckiness of reimplementing the vertical pipe and site name suffix of the window title in my own code. Maybe some sort of route alter or subscriber?


texts: User Not be Sent to Front Page after Submitting Contact Form

texts:
After submitting contact form (on contact page), the user automatically is sent (redirected) to front page. How can I avoid it? (user remain on contact page)

Thanks


texts: Add an item among those displayed in a Views block that links to the item creation page

texts:
The goal:

How do I add the "Add new project" item as the first among the other projects shown in the Views block? The content would link to the project creation page (node/add/project) ?

Please suggest other methods/alternatives if this is not feasible.


texts: What are the options for an e-card wizard module?

texts:
I am looking at creating an e-card wizard and would like to know if there are any modules that exist which would help with this.
A link should be added to a node and then the user should be able to create an e-card using information from this node. They need to be able to select a theme/image for the card, add a caption, add their email and the recipients email and then send it. Options to then share this with Facebook or Twitter etc should then be available.

Anyone done anything similar before?


texts: EntityMetaDataWrapper exception when calling commerce_cart_product_add()

texts:
In brief, I'm trying to create and order and add a line-item as part of a form submission callback. Here's the sauce:

if (!commerce_cart_order_session_exists())
{
    $order = commerce_cart_order_new();
    $order->log = t("Created by $product_type checkout page.");
    commerce_cart_order_session_save($order->order_id);
} else
{
    $order = commerce_order_load($form_state['order']->order_id);
}
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$sku = get_sku($product_type, $adj_age);
commerce_cart_product_add($uid = 0, $sku = 2, $quantity = 1, $display_uri = NULL, $combine = FALSE);

I'm getting the following error:

EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 83 of /srv/www/mtairy.toomodernmedia.com/public_html/sites/all/modules/entity/includes/entity.wrapper.inc).

In some very similar case I was getting the same error message, but in the commerce_cart_product_add function definition where the metadatawrapper was being called.

If I comment out the commerce_cart_product_add() line I can instantiate an order object. Not sure what I'm doing wrong here.


texts:
I am following this tutorial on how to migrate files from D7 into D8.

I have the migration setup with the following yml configuration:

uuid: a685a4e0-1022-4bf2-a787-f6f1bef587ea
langcode: en
status: true
dependencies: {  }
id: d8_files
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
  - Content
migration_group: D7-TO-D8
label: 'D7 to 8 Public files'
source:
  plugin: d7_file
  scheme: public
  constants:
    # source_base_path: 'sites/default/files/'
    # source_base_path: '/var/www/d8/sites/default/files/'
    # source_base_path: '/var/www/d8/sites/default/files/d7_download/page/files/'
    # source_base_path: '/sites/default/files/d7_download/page/files/'
    # source_base_path: '/var/www/d7/sites/default/files/page/files/'
    source_base_path: '/var/www/d7/sites/default/files/'
process:
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@source_full_path'
      - uri
  filemime: filemime
  status: status
  created: timestamp
  changed: timestamp
  uid: uid
destination:
  plugin: 'entity:file'
migration_dependencies: null

Migrate-status indicates I have over 2000 files detected in the D7 database ready for migration but when I try migrating it just reports 0 migrated content and errors, shown below:

My guess is the migration does not know where to find the images but I have tried a variety of paths to those image by altering the source_base_path value however I still get no migrated files.

Can anyone help, please?

UPDATE:

I found out more on the issue preventing the migration.

When I checked the logs for the d8_files migration, I found messages such as the following:

File'/var/www/d8/sites/default/files/d7_download//sites/default/files/field/image/imagefield_OvRwVF.jpeg' does not exist

The issue is how the module is creating the file url.

In the source section of my d8_file.yml, I had set the following:

source_base_path: '/var/www/d8/sites/default/files/d7_download/'

... which is the absolute path to the directory containing the files I wish to migrate.
The migrate module is concatenating /sites/default/files to the end of the path which makes it wrong. I have tried doing things like navigating up the directory path by using ../../ in the source_base_path settings but it doesn't work ... it's just seen as a string.

Can anyone tell me how to correct this?

In the process section, I saw the following:

process:
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath

I suspect that concat value is the problem. BUT, I have no idea what other value to set it to.

PS: Can anyone advice where is the system to find such information on any plugin ???


texts: Is there a way to avoid implementing a logic in the view template?

texts:
Some where I have read that we should use views template xxxxx.tpl.php file to not implement complex logic. I want to show a search results message to the user. The message is not made of mere row count but it has little bit of logic depending on what options he has selected.

I have implemented this logic in my view mymodule-view-grid--apartments--listing-row-filtered.tpltemplate.tpl.

I don't think this is complicated logic that's why I went on and implemented this logic but a question always bothers me is that where should I implement this logic if at all I have to implement it outside and how to pass this variable to this template.

<?php

  $view = views_get_current_view();
  $rowCount = $view->total_rows;

  isset($view->exposed_input['field_location_tid'])?$ltid = $view->exposed_input['field_location_tid']:$ltid = 'All';

  //force to all if landing directly
  $city = taxonomy_term_load($view->exposed_input['field_city_tr_tid'])->name;
  $locationName = $ltid == 'All'?'':' in ' . taxonomy_term_load($view->exposed_input['field_location_tid'])->name;
  //
  $resultText = "Properties in $city: Your search criteria matched $rowCount properties$locationName";

?>

<?php print($resultText);?>

... and rest of the template follows unchanged


texts: Mass Contact shouldn't be applying Glossify filter

texts:
I'm working on a Drupal 8 site which is both sending out emails with Mass Contact and uses the Glossify plugin filters in a different part of the site. However when sending emails using an "email" text format that doesn't include the Glossify filters, the Glossify filter is still being applied to the text sent by the email. It's picking up terms and turning them into a hyperlinks like we have Glossify set up to do. It's strangely not showing up in the "archived" email on the site, but it is showing up in the actual emails that are sent out.
Could there be something misconfigured or is it likely a bug in one of the modules? If it's probably a bug would it be a bug in the Mass Contact or the Glossify module?
I've started to try to look into the code of the modules themselves, but I'm not an expert in Drupal modules so any help would be appreciated.


texts: How can I display a taxonomy term's parent ID in Views?

texts:
I am using a JSON plugin to Views to output taxonomy terms as a JSON object for Javascript manipulation. I was to be able to include the parent ID in this output.

In view I see "Taxonomy term: Parent term" under relationships and I have added that to the view. But under "Fields" -> "Add" there is still no "Parent term" listed in the available fields. I'm pretty sure the "pid" should be available. Is there some other way of accessing that field via the Views UI?