texts: How do I sort two different date content-types in a view?

texts:
I have a view that filters two content-types (single event, and serial event) by date. The content-types have their own date-field (one with, one without date-repeat option).

The view shows all the "serial events" first, and afterwards the "single events".

How can I change this order?

Is it because I use two different date-fields?

The sort criteria are the following:

Format
Format: Unformatted list | Settings
Show: Fields | Settings
Fields
Content: single event
Content: serial event
Filter criteria
Content: Published (Yes)  AND Content: Category (exposed) | Settings AND Content: Type (in single event, serial event)  OR Date: Date (node) (Content: single event (field_serialevent)
OR Content: serial event (field_singleevent) >= now)

I am using Drupal 7.14, with the latest versions development snapshots of the Views, Calendar,  and Date API modules.


texts: Enable drupal_add_tabledrag on dynamically added rows

texts:
I have used drupal_add_tabledrag to get Drupals sorting feature for a table, however, I cannot find any function to add the dragging feature to <tr> dynamically added with JavaScript to this table.

Does anyone know function Drupal provides to do this, or how you are supposed to do it?


texts:
I did a D6 to D8 migration in 10/2015 and I recreated the blocks and views not migrated.  But in the mean time 6 month later my D6 original site has been getting more content.

What is the best way to bring all of that content from the last 6 month from my D6 to my migrated D8?


texts:
I am just researching something for a client and membership functionality

Rather than allowing visitors/ unregistered users the ability to see a teaser and then full access to content if they register we would like visitors to see say 3 articles and when they click on the 4th they then have to register.

SO rather than restricting content by type or category the restriction is quantity before you have to register.

Does anyone know of any modules which deal with this type of functionality?

Thanks in advance


texts: Drupal Node Display Main Image or Video not both

texts:
We have a content type that in addition to the body field it has a field for Image and another field for Video.

Both video and image are currently displayed at the top of the node, in Node > Manage Display. But if there is already a value for video field, that should be all that needs to display. Unless the video field has no value in which case, display the image field.

In other words, we want to have a condition where the image field is hidden IF there is a value for the Video field. If no data is present for video filed, display image.

Does anyone have an idea of how this can be accomplished?


texts: How to prevent actions using Flag (or similar) module?

texts:
The Goal: I'm trying to setup functionality similar to a library with downloadable files. Only one user can download a file at a time.

The Solution: Use the Flag module.

Open to suggestions but through my research it seems like people are using the Flag module for this type of functionality. My question is how do I actually get this to work? I'm using a file field to add a file to a node. An admin comes along, wants to "checkout" that file, and they click the checkout flag, and then download the file. Now no other admin can download that file.

Once the original admin comes back, they can just click the flag again, setting it to open. (I know, they aren't really returning a digital file.) They just need to simulate returning it by basically just telling the system someone else can get this file.

Anyone set up something similar to this or just have an idea of how I would do this? Thanks for any suggestions and help.


texts: Problem with the body field after upgrading to 7.7

texts:
I recently upgraded to 7.7 because of the security updates, but now, when I try to add content there is no body field... and when I go check the module list I see this message on top of the list.

  Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 of /var/www/gisele-drupal/modules/field/field.info.inc).
      Notice: Undefined index: module in _field_info_prepare_instance_display() (line 350 of /var/www/gisele-drupal/modules/field/field.info.inc).
      Notice: Undefined index: module in _field_info_prepare_instance_widget() (line 382 of /var/www/gisele-drupal/modules/field/field.info.inc).
  […]

Does anyone know what could be going on here, and how can I solve this?


texts: I am trying to add Node ID in contextual filters but it seems there isn't Node ID anymore.


texts: How to contextual filter a view by a field value?

texts:
QUESTION

I have an address field in my user form, from the address field module.

I have a content type named "project" which also have an address field and users can pick up a country related to the country the project will belong to.

I want to make a view filtering all the projects related to the logged-in user's address country field.

TRY

My trick is to make a user-view with a author-content relationship filtered on the content type project. Now I have the two fields in the view, I'm trying to compare them with a contextual php filter.

I tried to use php filter based on this post

$node = node_load($data->nid);
$user = user_load($user->uid);

$field_user_country = field_get_items('user', $user, 'field_user_address_country');
$country_user = field_view_value('user', $user, 'field_user_country', $field_user_country[0]);

$field_project_country = field_get_items('node', $node, 'field_project_range_country_country');
$project_country = field_view_value('node', $node, 'field_project_country', $$field_project_country[0]);

if ($price_a = $price_b) {
  return TRUE;
}

The fact is field_user_address_country is actually stored under field_data_field_user_address in the database.

Same for field_project_range_country_country which is stored under field_data_field_project_range_country

What is the best way to do this ? Is what I'm trying to do possible ?

UPDATE 1

Clear code which give me an ajax error :

$node = node_load($data->nid);
$user = user_load($user->uid);

$field_user_country = field_get_items('user', $user, 'field_user_address_country');
$country_user = field_view_value('user', $user, 'field_user_address_country', $field_user_country[0]);

$field_project_country = field_get_items('node', $node, 'field_project_range_country_country');
$project_country = field_view_value('node', $node, 'field_project_range_country_country', $field_project_country[0]);

if ($country_user == $project_country) {
  return TRUE;

UPDATE 2

Here the new code which is still giving me an ajax error :

  EntityMalformedException : Missing bundle property on entity of type
  node

$node = node_load($data->nid);
$user = user_load($user->uid);

$field_user_country = field_get_items('user', $user, 'field_user_address_country');
$country_user = field_view_value('user', $user, 'field_user_address_country', $field_user_country[0]);

$field_project_country = field_get_items('node', $node, 'field_project_range_country_country');
$project_country = field_view_value('node', $node, 'field_project_range_country_country', $field_project_country[0]);

if ($country_user == $project_country) {
  return $country_user;
}

Have a bigger ajax error (like 15 lines) if I put

global $user
$node = ($node = menu_get_object()) ? $node->nid : NULL;

At the beginning of my code.


texts: display alternate url after redirect using $base_url

texts:
1) have 2 d8 sites: site1.com and subd.site2.com in a multisite server (no root access)
  2) would like site1.com/subd to redirect to subd.site2.com BUT display url site1.com/subd
  3) I now have an .htaccess redirect

RewriteCond %{HTTP_HOST}  ^site1.com$ [NC]
      RewriteRule ^/subd/(.*) http://subd.site2.com/$1 [P,L]

4) site1.com/subd NOW redirects to subd.site2.com but displays subd.site2.com
  5) when inserting $base_url = 'http://site1.com/subd' in settings.phpget server error


texts: individual user profile on click of user name in view

texts:
I have a view of displaying uploaded image content by different users.
The content is displaying in box in below manner..
i.uploaded image
ii.title of the image
iii.user name and profile picture
iv.category

Now i want that
1. when the user clicks on either image or title one popup will open in a lightbox. in that popup the content should be the node content with all details.
I have done successfully with the module lightbox2 only to popup image but i want that particular node content in that popup.

2.After click on user name or profile picture that page goes to the particular users page with their details and their upload content.
Till now when i click on this link that particular user details opens in tab. but i want either all tabs merge in to one page or the things will display like i expained above.

please help me i am working it on since last 1 week but i am unable to find any solution..

please help/guide me ..

Thanks


texts: How do I alter the path of an uploaded image/file such that it includes the path of the node I attach it to via an image field?

texts: I added an Image Field to my Node content type. Now, when I upload an image "image1.jpg" that is attached to a node mysite.com/note/123, I want the uploaded image's path to be mysite.com/node/123/image1.jpg. How do I achieve this? I've tried to change the subfolder of the image with a token. I used the token [current-page:path], but that doesn't return the node where I'm attaching to, but the last page that was visited. (Which might be the node edit form or something completely different with ajax, say)


texts:
I have this problem: I created three content types. Actor, author and musician.
An user can modify own actor, author and musician profile, if his role is one of these.

A user can have more than one role, so, he can be actor, author and musician.
An actor can be a man or a woman, so his role canbe actor or actres.
In user menu I must have links on pages for these roles, so, an actor can have actor/[user:name] and an author can be author/[user:name].
Title of these links should be [user-name] actor or actres depending on the role.

Ok, I can use user-name token, but how can I retrieve the role?
Can I use php code on title of link?


texts: Change an existing textarea to full_html

texts:
I have PET module enabled. As per my requirement, I have to change the mail body to a full_html one from normal textarea. It changes to ckeditor when I changed #type and #format. following is my code:

case 'pet_form':
  $form['mail_body']['#type'] = 'text_format';
  $form['mail_body']['#format'] = 'full_html';
break;

But when form submitted the mail body value turned to an array() instead of HTML based string.

Any idea how to resolve this?


texts: Does Drupal 8 core by default collect visitors data?

texts:
I am searching a lot since last few days but not getting an answer. I am in process of preparing Privacy Policy of site. I am not providing any user registration or user login facility but anonymous user can post comments. Now, question arises after I read following Q&A on DA,

Don't collect IP addresses in Drupal 7

Now, since I have no intention to collect any user information(have not enabled statistics module), then I can simply write, "I do not collect any user information". Again, question comes, what if the code is collecting IP address/Hostname without our knowledge.

So, if there is a way to know what information are collected, and how saved then we can be sure about that, and can state in privacy policy or If Drupal core is not collecting any data, then also we can be sure about that  and write "We do not collect any visitor's data". Is there a way we can know?

Note: Please let me know, if this question is going toward Privacy policy(away from drupal), I will move this to SO. But, again it is related Drupal CMS code, so I thought to ask here first.

UPDATE:

Have raised the issue at Drupal core: Legal privacy policy statement of Drupal core

and it you see the comment there is a link to other issue: Privacy Concerns as GDPR Compliance, which says there is already work going on and regarding this module creation is underway, module will be General Data Protection Regulation.

Please add comments in issue, if you want to add some suggestion.


texts: Local vs CDN libraries and how to check for available updates

texts:
For contributed Drupal modules, you can check whether you are using the latest version release of the module or not, by using any of the available methods such as Drush, Drupal console, Composer and UI.

What about the libraries used by those modules !?

How do I know if some of the libraries i have on my website are outdated and need to be updated ?!

To name a few, libraries for:

Webform.
Business Rules.
Font Awesome.

Note: I am asking about the libraires used locally and not via CDN.

I am aware of the "one question" policy to simplify the questions asked, but since my other question is related to the first one so:

I don't like to use the CDN version of any library because when switch to the development website on my offline localhost, the CDN won't work and I must anyway to download the Libraires locally on my machine.

So my second question is:

What is the best in term of performance, using the CDN version or the Local version of libraries ?

Maybe, not sure, for development website running on localhost we could use the local version of libraries and add those folders/files to the .gitignore file so they will be not added to the Git repo

Thank you,


texts: How to get an array of values of node ids from entity reference field with EntityMetadataWrappers

texts:
I'm using a EntityMetadataWrapper on a profile2 entity. One of the fields is a multi-value entity reference field to nodes.  I want to simple get the node ids as an array, so I can do a quick in_array() to see if a value already exists.

I can't seem to find how to easily do this.


texts: How to check if a multi value reference field already has a value

texts:
I need to check if a multi-valued reference field (referencing other nodes) in a node has a specific value already present to avoid duplicates.

here is the code:

$portFolioNode =  \Drupal\node\Entity\Node::load( $form_state->getValues()['portfolios'] );

//now save location id to reference field.
//$portFolioNode->field_portfolio_locations[] = ['target_id' =>  $form_state->getValues()['location_nid']  ];

// how can I check if location_nid is present already?
$portFolioNode->field_portfolio_locations[]  = $form_state->getValues()['location_nid'] ;

$portFolioNode->save();

Any help will be appreciated greatly. Thanks!


texts: How do I migrate paragraph translations?

texts:
So I am trying to migrate paragraphs from Drupal 7 to Drupal 8. I have created 3 yaml for the same and execute them in below order:

Paragraph YAML (migrate_plus.migration.paragraph_latest_story.yml)
Node YAML (migrate_plus.migration.pp.yml)
Node Translation YAML (migrate_plus.migration.pp_translation.yml)

Migrations for paragraphs works fine until I run Node Translation YAML. When I run translation for node it overrides existing paragraph values with the translated one. Below is my code:
Latest Story Paragraph YAML:
id: paragraph_latest_story
label: 'Paragraph Migration - Latest Story'
migration_group: custom
migration_tags:
  - Drupal 7
  - Paragraph
  - Field Collection
source:
  plugin: d7_paragraphs_item
  bundle: latest_story
  field_name: field_latest_story
  new_revisions: true
process:
  langcode: langcode
  # default_langcode: default_langcode
  # revision_translation_affected: revision_translation_affected
  # content_translation_source: content_translation_source
  field_card_title:
    plugin: sub_process
    source: field_card_title
    process:
      value: value
    revision_id: revision_id
  field_story_template_selector:
    plugin: sub_process
    source: field_story_template_selector
    process:
      value: value
    revision_id: revision_id
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: latest_story
migration_dependencies:
  required: {}
  optional: {}

Node YAML
id: ct_pp
label: 'Migration Content Type: PP'
audit: true
migration_group: custom
migration_tags:
  - Drupal 7
  - Content
  - Domain
  - Workbench
  - Base
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
  plugin: d7_node
  node_type: ct_pp
  constants:
      field_collection_list:
        - 'field_latest_story'
process:
  nid: tnid
  type: type
  langcode:
    plugin: default_value
    source: language
    default_value: "und"
  title: title
  uid: node_uid
  status: status
  created: created
  changed: changed
  promote: promote
  sticky: sticky
  revision_uid: revision_uid
  revision_log: log
  revision_timestamp: timestamp
  field_banner_sub_title:
    -
      plugin: get
      source: field_banner_sub_title
  field_latest_story:
    -
      plugin: skip_on_empty
      method: process
      source: field_latest_story
    -
      plugin: migration_lookup
      migration: paragraph_latest_story
      no_stub: true
    -
      plugin: sub_process
      process:
        target_id: '0'
        target_revision_id: '1'
destination:
  plugin: entity:node
migration_dependencies:
  required: {}

Node Translation YAML
id: ct_pp_translation
label: 'Migration Content Type: PP - Translation'
audit: true
migration_group: custom
migration_tags:
  - Drupal 7
  - Content
  - Domain
  - Workbench
  - translation
  - Multilingual
class: Drupal\node\Plugin\migrate\D7NodeTranslation
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
  plugin: d7_node
  node_type: ct_pp
  translations: true
  constants:
      field_collection_list:
        - 'field_latest_story'
process:
  content_translation_source: source_langcode
  nid:
    plugin: migration
    source: tnid
    migration: ct_pp
  type: type
  langcode:
    plugin: default_value
    source: language
    default_value: "und"
  title: title
  uid: node_uid
  status: status
  created: created
  changed: changed
  promote: promote
  sticky: sticky
  revision_uid: revision_uid
  revision_log: log
  revision_timestamp: timestamp
  field_banner_sub_title:
    -
      plugin: get
      source: field_banner_sub_title
  field_latest_story:
    -
      plugin: skip_on_empty
      method: process
      source: field_latest_story
    -
      plugin: migration_lookup
      migration: paragraph_latest_story
      no_stub: true
    -
      plugin: sub_process
      process:
        target_id: '0'
        target_revision_id: '1'
destination:
  plugin: entity:node
  translations: true
migration_dependencies:
  required: {}


texts: Add pagination to the results in custom module after split the row to many sub rows

texts:
I try to build new module (Drupal 7), in some page I show the results to the user as a table like the following:

<?php
    $header = 'bla bla bla'; //header come here
    $query = db_select('myTable', 't')
        ->fields('t', array('field_1', 'start_date', 'end_date', 'due_date'))
        ->extend('TableSort')
        ->extend('PagerDefault');

    $result = $query
        ->limit(10)
        ->orderBy('t.startdate')
        ->execute();

    foreach ($result as $row) {
        $rows[] = array('data' => (array) $row);
    }

    $form['tablesort_table'] = array(
        '#theme' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#empty' => t('Sorry, there is no results to show'),
    );
?>

and this of course works perfectly (each page has 10 rows), but for some reasons I have to split each row to multi sub row according to the start date and end date like the followin

foreach ($result as $row) {
    $timeInLoop = $row->start_date;
    while($timeInLoop < $row->end_date){
        //split the row to multi row (one week for each row)
        $timeInLoop = strtotime(date("Y-m-d", $timeInLoop) . " +1 week");
        $row->due_date = date("Y-m-d", $timeInLoop);
        $rows[] = array('data' => (array) $row);
    }
}

and here is my problem:
if some row has 10 weeks and other row has 2 weeks the total rows in the page will be more than 10 rows
how can I make them 10 rows in each page ???
thank you for your help


texts: How to create a url pattern for a specific node

texts:
I have a node with the path: http://www.example.com/test

I would like all paths that begin with /test/ to go to this node. url like these:
http://www.example.com/test/a/b/c
http://www.example.com/test/a?bc

all should be redirected to this node.

How can this be accomplished?


texts: Can I get the absolute path to the frontpage in theme_preprocess_html?

texts: Is it possible to get the absolute path to the homepage or <front> eg: https://www.domain.com/homepage in the theme_preprocess_html hook? I tried global $base_url but it throws an error.


texts: Create a field linked to a vocabulary with Drush

texts:
Let's say I have created a taxonomy vocabulary called ABC.
For this vocabulary ABC, i want to create many fields using Drush.

I've tried

drush field-create ABC myfield,text,text_textfield

It works, doesn't give any error, but if I go to the admin panel, I click on structure => taxonomy then in the list I see ABC, I click on "Edit" then I click on the tab "Manage fields" where I expect to see my field. Because (correct me if I'm wrong) I think that the drush command line field-create ABC myfield should have added it. But no.

It's not there. But if I click on the combo of the "Add existing field" option, in the list, there's the myfield that I've just created!

It seems there "link" between ABC and myfield is not created. myfield is  created, but it's not "included" in the ABC fields.

Am I doing something wrong, or missing something?


texts:
I'm trying to export menu links with features but it saves the node id in the feature, but obviously the nid is different in dev, test and production.

I can't use UUID because nodes are created in every environment.

Is there a way to export menu links with alias and not with nids?


texts: How to make Simple hierarchical select display links instead of dropdowns?

texts:
I'm using the Simple hierarchical select module in my views.

Is it possible to display links instead of dropdowns?


texts: Meaning of Error: Cannot redeclare bootstrap_preprocess_region()

texts:
I'm setting up a Drupal Bootstrap subtheme, and ran into this fatal error when trying to clear my cache. Something seemed to want to redeclare a bootstrap preprocess function:

  Error: Cannot redeclare bootstrap_preprocess_region()

This caused the whole site to go down and Drush to fail any time I tried to clear or rebuild the cache.

Why is this happening?


texts: product display image not showing drupal

texts: I have a question about Drupal Commerce (I'm using Drupal 7). I've added a number of products and created a multi-product display for them. I added a product image (it's common for all these products) to the product display. I also have a view of all product displays with images. But when I click and go to the product price and add to cart form, the product image does not show up. What am I missing??? (I did the same on the localhost before and everything worked fine, but probably I forgot to configure something)


texts: What permissions are needed for omega tools to create subtheme

texts:
I am looking to use Omega Tools, and similar modules quite a bit in the near future, and I am running into this error when trying to create a subtheme using Omega Tools:

I'm at least familiar with the concept of permissions, but I'm unfamiliar with what permission needs to be given to what.  Also, is this something that should be done?  I know that write permissions shouldn't be given willy-nilly.

Note: ygf is the directory for the site.  The current permissions on the folder are rwxrwxr-xThe all folder, which is the default gives the same error.


texts: How to rearrange views PHP sorting criteria?

texts:
Usually, it works fine when I rearrange two or more sorting criteria within a Views (simple drag and drop) but in my case (Content fields grouped by taxonomy terms), one of the sorting criteria is a Global:PHP (based on a PHP field) and it seems like it is always treated first whatever level I choose? And of course, I need it to be treated secondly.

EDIT1 : Here is the problem in details

I have a list of nodes with pagination (1-15, 16-28, etc.). I also have a taxonomy field to group the nodes (categories). I need to sort the nodes by taxonomy terms (according to the weight) and secondly by first page. I get the first page using a PHP field to extract the data from the pagination. If I use the pagination field directly, the sorting is wrong (page 100 will appear before page 11, "alphabetical order").

Finally, I need :

Term 1

Node 1 pages 1-15

Node 4 pages 78-100

Node 12 pages 167-184

Term 2

Node 2 pages 16-45

Node 10 pages 110-125

Term 3

etc.

Any idea?

Thanks.

Related posts :

Cant get desired results for multiple sort criteria in a view

Sort criteria is ignored in Views

Views: custom field for sort criteria

EDIT2 :
As suggested by Smalution, a custom module could help. I am thus working on the little code needed to sort my View using a custom PHP field. I am using hook_views_query_alter and add_orderby but I can not find the right way to write it since the custom PHP field is not stored in a table like any other standard Drupal fields (the PHP field is computed when the View is calculated). Could anyone help me to complete the code given by Smalution? Thanks for any tip. Tell me if more details are needed.


texts: Override an url with hook_menu_alter : problem with the file path

texts:
In 'mymodule', i try to override a menu url with hook_menu_alter, like this :

global $base_url;

$items['node/%node/delete'] = array(
  'page arguments' => array('myfunction', 1),
  'file' => $base_url .'/'. drupal_get_path('module', 'mymodule') .'/includes/custom_node_delete_confirm.inc',
);

I have an error because the file path is relative and begins with a "/"

Failed opening required
'/http://localhost/mysite/sites/all/modules/mymodule/includes/custom_node_delete_confirm.inc'

and this doesn't work too:

'file' => 'includes/custom_node_delete_confirm.inc'

How can i do this ? Thank You


texts: How to load a library only once, or how to check if a library has been loaded?

texts:
I am making an asynchronous single page application in Drupal 8. So far everything is working nicely. However, it has a lot of libraries that are needed for a lot of different things, depending on what the user decides to do.

The libraries are different depending on which content type is loaded. I want to only load the library ONCE when a user loads a content type for the first time.

Using the below code the library is attached every time the content type gets loaded. Leading to multiple instances of each library.

function mytheme_preprocess_node(&$variables) {
    $node = $variables['node'];
    switch($node->getType()){
        case 'nodeone':
            $variables['#attached']['library'][] = 'mytheme/liba';
            break;
        case 'nodetwo':
            $variables['#attached']['library'][] = 'mytheme/libb';
            break;
        case 'nodethree':
            $variables['#attached']['library'][] = 'mytheme/libc';
            break;
        default:
            break;
    }
}

I can't do a preproccess_page as the content types are loaded asynchronously and would imply loading everything at once. I can't attach the library to the twig template as again, it happens at the node level, not the page. I have tried to attach the library to a view template, but the same issue remains, it gets loaded multiple times.

If I could do some form of check to see if the library has already been loaded, I think that would be sufficient.


texts: Display Suite custom function field not firing

texts:
I need to add a Display Suite function field to a node.  I set up my hook, and my field shows up and I can add it to my content type in display.  However, the function isn't getting called, and it looks like it should.  I stripped my code down so I can debug this.  My custom function is in my .module file.

function MYMODULE_ds_fields_info($entity_type)
{

    if ($entity_type != 'node')
        return;

    $fields = array();

    $fields['splittitle'] = array(
        'title' => t('Split product title'),
        'field_type' => DS_FIELD_TYPE_FUNCTION,
        'function' => 'MYMODULE_ds_field_splittitle'
    );

    return array('node' => $fields);

}

function MYMODULE_ds_field_splittitle($field)
{

    return 'test';
}


texts: Views -- failed to override default templates despite being bold in "theming info"

texts:
I just created a new template for my view with the most specifically name. The template itself can be displayed as bold in "theming info".

However, it fails to override the original template, I can even see the content of the later ones by clicking "Display output" or "Style output" at "Page: Theming information". Any changes I've done to the original files can be successfully reflected in "theme info" while my newer customized templates seems to be ignored.


texts: Can we add a new column to field collection in edit form?

texts:
I created a topic before with this question, but i write another to be more exact on what i want to do. I have an entity with several field collections and in this field collections, several fields (text, checkbox, entity ref...). When i open the form in EDIT mode, i want to add a new column to my field collection and in this column i would add a simple link to go to another page. So in my other topic we told me to use "link" module but it's not working on EDIT form but just in VIEW mode. So i searched how to add a column programmatically in drupal. I tried in my HOOK_form_alter to alter the form but i can't...

I can add a new column with jQuery i think but that won't be the best solution.

Someone got an idea ?

Thanks


texts: How to force rendering by the site theme instead of the admin theme?

texts:
When rendering HTML in hook_node_presave(), everything works as expected when I save the node manually.
However, when I use the "Save content" action on the content admin view (at /admin/content), then the page is rendered with the admin theme templates (Seven), instead of the templates of my custom theme/the site theme.
I tried using both Claro and Seven as the admin theme, and I get the same result: I can save the page manually and the site theme's templates are used, but if I use the "Save content" action to bulk re-save nodes, they are rendered incorrectly with the admin theme templates.
Here's the code that is causing the issue:
function MYMODULE_node_presave(NodeInterface $node) {
  $content_type = $node->getType();
  if ($content_type == 'page') {
    // Render the entire node and save that HTML to a specific field.
    $render_controller = \Drupal::entityTypeManager()
      ->getViewBuilder($node->getEntityTypeId());
    $render_output = $render_controller->view($node, 'mymarkup_torender', 'ja');
    $html = \Drupal::service('renderer')->renderPlain($render_output);
    $node->set('field_text_cached_html', $html);
    $node->field_text_cached_html->format = 'mymarkup_processed';
  }

Is there a way to force Drupal to use the site theme instead of the admin theme when rendering?
On the Appearance administration page, "Use the administration theme when editing or creating content" is unchecked.


texts: repeated results with Views Slideshow results and commerce products

texts:
I have a slideshow view where I am showing most recently discounted items.

each product display has 8 different variable combinations therefore, 8 product SKUs connected to the product content.

I have my view filtering by Content:product. However, it is showing all 8 products for each piece content.


texts: Setting automatically created taxonomy terms using rules module

texts:
I am using the rules module to automatically create a taxonomy term when i create content of a certain type.  I would also like to automatically populate the taxonomy term reference in the the created content. I have tried many different configurations using the set data function in rules however it does not ever set the taxonomy term to the the new-term which is created.

Is there any way that this operation can be carried out using rules.

I have exported the rule for you to take a look at.

/**
 * @file
 * advertising_region_creator.rules_defaults.inc
 */

/**
 * Implements hook_default_rules_configuration().
 */
function advertising_region_creator_default_rules_configuration() {
  $items = array();
  $items['rules_auto_taxonomy'] = entity_import('rules_config', '{ "rules_auto_taxonomy" : {
      "LABEL" : "Auto Taxonomy",
      "PLUGIN" : "reaction rule",
      "REQUIRES" : [ "rules" ],
      "ON" : [ "node_insert" ],
      "IF" : [
        { "node_is_of_type" : {
            "node" : [ "node" ],
            "type" : { "value" : { "savings_viewer" : "savings_viewer" } }
          }
        }
      ],
      "DO" : [
        { "entity_create" : {
            "USING" : {
              "type" : "taxonomy_term",
              "param_name" : "[node:title]",
              "param_vocabulary" : "2"
            },
            "PROVIDE" : { "entity_created" : { "new_term" : "New Term" } }
          }
        },
        { "data_set" : {
            "data" : [ "node:field-savings-viewer-region" ],
            "value" : [ "new-term" ]
          }
        }
      ]
    }
  }');
  return $items;
}

I apologize if this is posted in the wrong format I am new to all of this but will keep trying to get better.


texts:
I'm trying to add a Google Plus html tag via direct linking (see here) to my head but can't get it to work. What I'm trying is this inside my template.php file:

$googleplus = array(
    '#tag' => 'a',
    '#attributes' => array(
        'rel' => 'publisher',
        'href' => 'https://plus.google.com/+MyPage'
    )
);
drupal_add_html_head($googleplus, 'googleplus');

Nothing shows up for me. Is there a better/working way of doing this?


texts: Unable to install site (Drupal + CiviCRM) in french

texts:
After creating a new platform with french translations I am unable to see french words anywhere. From what I see in logs every is installed in French but when using the website nothing is...

I even tried to switch languages but nothing is working !

Any ideas ?

Thanks :D


texts: Expose Drupal nodes content throught soap

texts:
I'd like to build a SOAP server with Drupal but I have some problems.
I've installed the soap server module (and i'm scared because of the beta status since 2011 ...), and the services module.
I've created a resource and checked "node" with "api" as endpoint.

With a SOAP client, when I get http://localhost/api?wsdl, I get information but nothing about node management. I only get methods to manage system and user.
In addition, I've managed policies to give full access on node, services and SOAP server to all users.

Did I miss something?


texts: How do I programmatically create a node with an entity reference (to an user)?

texts:
It is kind of strange because my code creates the node with the referenced user uid in node_field_data, but when I open this node the user reference isn't working. Then I navigated the database and found that, when I update the user reference field in the interface, it is also written as a new registry in the table node__field_user, so I guess I should insert it there too.

But, I don't know how to do this with the API, and I think making it with a SQL query probably means security issues and is probably much more complicated than however it can be done with the API.

This is my code:

  $node = Node::create(['type' => 'nodetype']);
  $node->set('title', $username );
  $node->uid->entity = $userId;
  $node->enforceIsNew();
  $node->save();


texts:
I have node type called online_users.
The node type has a field called field_website_id.
I would like to get the nodes that has a specific field_website_id.

I have try to make the following action but gets an error:

function get_list_of_users($site_id) {
$query = new EntityFieldQuery();
  $entities = $query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'users_online')
  ->propertyCondition('field_website_id', $site_id)
  ->execute();
  if (!empty($entities['node'])) {
    $node = node_load(array_shift(array_keys($entities['node'])));
  }
}

The error:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'node.field_website_id' in 'where clause': SELECT node.nid AS
  entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type
  AS entity_type FROM {node} node WHERE (node.type =
  :db_condition_placeholder_0) AND (node.field_website_id IS NULL ) ;
  Array ( [:db_condition_placeholder_0] => users_online [:entity_type]
  => node ) in EntityFieldQuery->execute() (line 1140 of /Applications/MAMP/htdocs/Drupal/includes/entity.inc).

What is the right way to do this?


texts: Inserting based on the results of a select query

texts:
Initially I had all columns under 1 table. In table shown below had one additional column for all media items.

  did | disclaimer_title | disclaimer_body | disclaimer_media_items

But for some reasons, I need to pull out the disclaimer_media_items column into separate schema. So now I have 2 tables.

Table 1 schema

  did | disclaimer_title | disclaimer_body

Table 2 structure:

  did_media | disclaimer_media_items

Now what I want is when I insert media in table 2, the results get stored for table 1.

i.e. I want to achieve same functionality of all columns under table 1 with two individual tables.

I know 2 things can work, either foreign key or Drupal joins. How can I achieve this?

Hope I explained it well.


texts: Programmatically load the contents of a Product in a particular product type

texts: I am developing an Ecommerce site and I am using Drupal-commerce module for it. I have an issue regarding loading the contents of a product which is: How can I programmatically get the contents of all the products in a particular product type?


texts: Views... two panes each contains a view.  One is the exposed filter, other is the fields.  How can they communicate?

texts:
I have have two panes each containing a view.  But, these views are and exposed filter and it's fields/results.  How can I make these views aware of each other?  I want results of the exposed filtered view to be displayed in the other fields pane.

I'm assuming this would be done through relationships.


texts: Can node reference be altered to include views pages?

texts:
I have a site where 'related pages' is a node reference CCK field for a node. Authors can add related pages (1 or more) to a node with the autocomplete functionality of node reference.

My question is the following: is it possible to extend the CCK node reference field to include non nodes, e.g. views pages, in this case?


texts: How do I write a template file for a specific input field?

texts:
I'm currently creating a custom theme for a drupal 8 site and I'm putting a comment section for blog posts like :

<section class="comment-section">
    {{ content.comment }}
</section>

That puts in the comment section, but now I want to style it. I have twig debug enabled and to customize a page or view I usually look at the inspector/page source and there are comments recommending file names such as page--node--1.html.twig and such. Unfortunately for these fields when I look for the textarea or title input the only suggestions are, for example, ../form/textarea.html.twig. I can't use those because they will effect every other textarea on the site, so how do I figure out what to name my file for these specific inputs?

I'm going to put in a screenshot of my elements console in case it has something to do with that:


texts: management menu invisible for the second administrator

texts:
I am using Drupal 7.26, and I need a second administrator user. I created a user who can see the authenticated user's menu, but not the management menu which I (as user #1) can see.

How can I fix this? I want the user I created with administrator role to have access to everything from the management menu.


texts: For a content type (place), on creation, as the user is entering the name field, I would like to check the previous records for that field. If there is a match, I will present it to the user to prevent duplicate entries. is there way to do this?


texts: Can you render a custom block in a view without adding it to the admin blocks page?

texts:
I made a custom block in my custom module.  I now want to show that block in the "No results" area of a view, but I can't get it to render (I don't see any error message, and I don't see any output).
Here is the block definition:
/**
 * Provides an 'New User' Block.
 *
 * @Block(
 *   id = "newuser_block",
 *   admin_label = @Translation("New user block"),
 *   category = @Translation("MYMODULE"),
 * )
 *

In my view, in the "No results" section, I added Rendered entity - Block, and set the Block ID to newuser_block.
However, the block does not get rendered.
This is because I did not add the block on the block admin page at /admin/structure/block. When I add the block on the admin page and use the admin page block ID (not the block machine name), the block is rendered correctly.
However, I don't want to add the block to the admin page because I only need this block in a few places on my site, so I was using Layout Builder to inject the block where necessary.
So, is there a way to inject a block by machine name (instead of by the ID used on the block admin page) in Views?


texts:
On any node in Drupal 7, I want to show a list of its child nodes.  How do I do this?  I basically want to create my own navigation system.

I'm still unfamiliar with the terms in drupal 7. I establish the hierarchy of nodes via the following steps:

go to admin dashboard menu and click on "Add content"
select the "Page" content type
fill out the fields
under "Menu settings," I select "Provide menu link"
I choose the parent node under the "Parent item' drop-down menu
save and publish


texts:
I had a migration that was working a few months ago on an 8.6 site before the JSON API module was part of core. Nothing has changed on the site I'm migrating to or from, but I'm now getting the following SQL error:

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column 'sourceid1' at row 1: INSERT INTO

{migrate_map_articles}

I don't have a column sourceid1 and it's not clear what it's doing in Drupal's migration module. Any idea what could be happening here?

For reference, I'm using this article: https://www.lullabot.com/articles/pull-content-from-a-remote-drupal-8-site-using-migrate-and-json-api


texts: Running regular Migrate in Cron leads to duplicate nodes

texts:
Related: Schedule Migrate to import XML data regularly

I am getting duplicate nodes every time I try to do a rollback/update. Is it because they are triggered when users visit the page (instead of me), or does it have something to do with my MigrateSQLMap?

EDIT
I have come up with a sort of workaround for this: I need to, instead of doing a rollback/migrate, I need to do something like what I outlined below. I just don't know how to put it together.
Each source item in the XML has an ID, which I have/will import ad the field_sourceid in the node.

Here are the steps I need:

Grab all source IDs of the nodes and source IDs of the XML
Check them against each other:

If the node's SourceID isn't matched in the XML, that means that node is expired. Delete it.
If there is a Source ID in the XML but nothing matching in the nodes, then this is a new node. Import it.
If the SourceID exists in the XML, we have a current node. Update it.

It was my understanding that you could not declare prepareRow() when you use XMLMigration. What do I do then? It seems like I need something like that here.


texts: Restrict editing of content based on form value in content type

texts:
I'm not sure of the exact way to word this. I'm "just the designer". Where I'm working we've traditionally made a role per content type to limit access to editing/creating certain kinds of content. On a new (D8) site we're working on, we'd like to have a single content type ("Room") and have different people be maintainers of those rooms depending on what's set in the "Building" field.

The idea is to avoid having a ton of mostly-similar Room content types (that would all require updating when we want a change). And also of course to avoid people from other buildings editing rooms that don't belong to them.

(I think it'd be fine to have either 1) the rooms originally created by an admin and just have the building field hidden/disabled/limited when non-admins edit, or 2) even let them create new rooms with the building field limited based on their role/permissions.)

I don't know if there's a built-in way to do this, or perhaps modules you could recommend.

The developer I'm working with seems convinced that the only way to accomplish this is to build a custom form in PHP that essentially duplicates Drupal's built-in form for the Rooms content type we've made (I'd really like to avoid this route, since it'd be a lot of hard-coded stuff that needs dev time, testing, maintenance, etc.). Thanks!


texts: Override a node page of specific content with views page

texts:
I want to create a views for overriding the node page for specific content. For example, when I click the link of a node in a list page, by default , it will go to the node page (e.g node/1), but I want to display a views page, so I can customize the views by views rather than customize the display in content type.

How can I do that?


texts: Calling a module function from jQuery and Ajax

texts:
I am getting some problems calling a custom module function from jQuery and AJAX.

ajax_example.module

function ajax_example_init() {
    drupal_add_js(drupal_get_path('module', 'ajax_example') . '/ajax_example.js', array('scope' => 'footer'));
}

function ajax_example_menu() {
  $items['ajax_username'] = array(
    'title' => 'Get Current User Name',
    'page callback' => 'ajax_example_get_username',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function ajax_example_get_username() {
  global $user;
  $user_name = $user->name;
  drupal_json_output($user_name);
}

ajax_example.js

(function ($) {
  Drupal.behaviors.ajax_example = {
    attach: function (context) {
      $.ajax({
        url: '/ajax/username',
        success: function(data) {
          console.log(data);
        }
      });
    }
  }
})(jQuery);

I am trying to call JavaScript by a JS Injector module using these commands.

(function($) {
  $.ajax({
    url: 'ajax_username',
    type: "GET",
    success: function (data) {
      console.log(data);
    }
  });
})(jQuery);

Unfortunately, I get the same 404 error again and again.

What am I doing wrong?


texts: I have created a user account. Then signed out of admin and logged in with the new user account. But the new account does not have a logout link, So how can i show it to the other users ?


texts: How to quickly create multiple Drupal 7 features?

texts:
I use Features and Strongarm to manage configuration of my Drupal 7 systems.

Until now I was creating features manually but even with Features Tools installed and ajax features status disabled it is a mundane process.

I want a separate feature for each contrib module and a separate feature for each view.

Is there a way to create features automatically or at least more quickly, maybe using drush ?


texts: pass array from module to render in template

texts:
I have a module name mysite.module in that module I have function named mysite_preprocess_panels_pane. That has an array and I would like to render this array inn panel.tpl.php. My code does not work. Any suggestion please, Thanks.

function mysite_preprocess_panels_pane(&$variables) {
 $ar = array('arg1'=> 'car', 'arg2'=> 'truck');
}

 <?php print  $ar['arg1']>


texts: how to modify the confirmation email in Ubercart?

texts:
I'm trying to modify the format and text of the confirmation email in Ubercart and I don't know from where....can anyone give me hint?
for example including some images or custom links in some parts of the email, quit the horrible yellow background of the site name , etc, etc...
I'm using Drupal 6

Here's what I'm receiving at the moment...


texts: How do you functional test your Commerce Kickstart 2.0 projects?

texts:
Since Commerce Kickstart 2.0 has its own Drupal installation, I don't see how to use SimpleTest with it.  I did find this documentation for the regular Drupal Commerce, not Commerce Kickstart 2 from what I can gather.  When I try to find what it alludes to in this documentation (CommerceBaseTestCase ), this does not exist in the Commerce Kickstart install that I can find.

So, how are people testing with Commerce Kickstart 2?  Let me be clearer with my question.  I have already installed Commerce Kickstart 2 and done some development.  I now want to create products and other elements programatically using SimpleTest to do functional testing.  However, SimpleTest starts with a clean install of Drupal.  This is not possible to use with Commerce Kickstart 2.0 because it has its OWN drupal version, and its not just a set of modules that I could enable programatically.


texts:
I've installed eu_cookie_complience module (eu_cookie_compliance 8.x-1.9). The documentation is nearly non-existent, but as much as this module is used, I'm hoping to find someone that has solved these issues.

The big one: how does one set the eu_only parameter to true? Crazy, but there does not seem to be any option in the Admin panel. I could hack the contrib yaml or worse the module and force things. But that's a bad idea.
How can I hook into or override eu_cookie_compliance and specify my own IP lookup. Though it isn't documented, apparently there are three ways to check to see if the user is EU (the smart_ip module, the geoip module, or geoip_country_code_by_name())  We already use IPSTACK and I want to leverage that.


texts: Script for collecting all translatable strings in the codebase?

texts:
I have hundreds of strings in my code-base that which translation i.e. strings inside t() function.

Is there a script that can traverse through my code-base and collect all the strings and export them to an excel file?

Or else, Is there any other way?


texts: How can I access block metadata from custom plugin instance?

texts:
Using the block_example module, I created two instances of the example_configurable_text block in the UI and would like to now access their underlying metadata, specifically uuids. By looking at the config table in the database, I can see that there is a record for each (select * from config where name like "%example%";). However, when I debug ExampleConfigurableTextBlock::build, I can't seem to access any of it.

I'm aware that configuration can be loaded via \Drupal::config('<name>'), but I need to be able to access the configuration dynamically from with my plugin class instance.

Is extending BlockBase the right way to go? Do I need to use derivatives? What is the connection between a block instance in the config table and an instance of a block plugin? So many questions.


texts: How to add subquery in views to remove particular type of rows?

texts:
I have applied join to users table with node_revision table like below:
function custom_overrides_views_data_alter(&$data) {

  $data['users']['node_revision'] = array(
    'title' => t('Users revisions authored'),
    'help' => t('Relate a user to their revisions'),
    'relationship' => array(
      'base' => 'node_revision',
      'base field' => 'uid',
      'relationship field' => 'uid',
      'handler' => 'views_handler_relationship',
      'label' => t('revisions bubbla'),
    ),
  );
}

And by creating view now I got number of revisions per user like below:

Westerberg (15752)
Eriksson (4305)
Jakob (4182)
Andersson (4153)

But now I want to remove those revisions which are created when user created node first time ie: will only show edits but not the revisions which are created first time when new node was created. To solve this logic is to remove nodes having below true:
excluding the “first time created” nodes (original node revision)
node.created = node_revision.timestamp

I tried using query alter but it uses quotes around field please suggest how to remove that ?
if ($view->name == "my_view") {

    $sub_query = db_select('node', 'n')
      ->fields('n', array('created'))
      ->condition('n.created', 'node_revision_users.timestamp');

    $view->query->where[1]['conditions'][] = array(
      'field' => 'node_revision_users.timestamp',
      'value' => $sub_query,
      'operator' => 'NOT IN'
    );

  }

Output problem is like screenshot:

Please suggest! thanks


texts: How can I get the node ID inside my implementation of hook_tokens()?

texts:
I am trying to implement a custom token using the following code.

/**
 * Implements hook_token_info().
 */
function hook_token_info() {
  $type = array(
    'name' => `enter code here`t('xyz'),
    'description' => t('module.'),
    'needs-data' => 'xyz',
  );
  $tokens['full_html_form'] =array(
    'name' => t('Full HTML Form'),
    'description' => t('Returns full HTML Form based on the node'),
  );
  return array(
    'types' => array('abc' => $type),
    'tokens' => array('mno' => $tokens),
  );
}

/**
 * Implements hook_tokens().
 */
function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();

  if ($type == 'abc') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'full_html_form':
        $output = core_module_get_node($node->nid);
          $replacements[$original] = $output;
          break;
      }
    }
  }

  return $replacements;
}

I don't understand how to pass node ID to core_module_get_node(). How can I do it?


texts: Invoke custom JS function in AJAX callback?

texts:
Is it possible to invoke a custom JS function in an AJAX callback?

function MY_MODULE_ajax_callback() {
  // Define a new array to hold our AJAX commands.
  $ajax_commands = array();

  // Create a new AJAX command that replaces the #page text with our own text.
  $ajax_commands[] = [CUSTOM JS FUNCTION]

  // Return our commandS
  return array('#type' => 'ajax','#commands' => $commands);
}


texts:
With Drupal 8 / Drupal Commerce 2, I can't find a way to disable product combining in cart (same products in cart appears on the same line with quantity > 1). In my use case I never want this to happen.

I found that in

/modules/contrib/commerce/modules/cart/src/Form/AddToCartForm.php

...we have a submitForm method which calls

$this->cartManager->addOrderItem($cart, $order_item, $form_state->get(['settings', 'combine']);

So it seems like my form needs to have a combine variable set to FALSE.

How could I set this variable or override

public function addOrderItem(OrderInterface $cart, OrderItemInterface $order_item, $combine = TRUE, $save_cart = TRUE);

...in

/modules/contrib/commerce/modules/cart/src/CartManagerInterface.php

...to define the default value of $combine to FALSE ?

Thanks


texts:
how can I make a pager with the pager class? I could not find anywhere how to do this with the EntityQuery class. I have a pager(10) that displays the last 10 items. I want to make a pager with numbers like
< 1, 2, 3, 4, 5, 6 >.

This is the code I have now:

class NewsArchive extends BlockBase {

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

    // Query for newest articles and return max 3 results.
    $query = \Drupal::entityQuery('node');
    $news = $query->condition('type', 'news')
      ->condition('status', 1)
      ->sort('created', 'DESC')
      ->pager(10)
      ->execute();

    // LoadMultiple News in $nodes variable
    $nodes = Node::loadMultiple($news);

    $path = base_path();

    // Return $nodes variable with name items to the module.
    return array(
      '#theme' => 'mytheme_news_archive',
      '#items' => $nodes,
      '#path'  => $path,
    );

  }
}

I have read somewhere that this was possible with the following code:

      $build['pager'] = [
        '#type' => 'pager',
      ];

How does this build pager (render) fit into my code? Can someone show me how to start?


texts:
function ruh_microblog_item($node) {
  $profile = content_profile_load('profile', $node->uid);
  $ava = theme_imagecache('microblog', $profile->field_photo[0]['filepath']);
  $noava = theme_imagecache('microblog', 'sites/default/files/imagecache/user_block_small/imagefield_default_images/no_photo.png');
  $content .= '
';
  $content .= l($ava, 'user/' . $node->uid, array('attributes' => array('title' => $profile->title, 'class' => 'micro'), 'html' => 'true'));
  $content .= l($profile->title, 'microblog/'. $node->uid, array('attributes' => array('class' => 'microname', 'title' => 'Микроблог - '. $profile->title)));
  $content .= check_markup($node->title, $format = 'Full HTML', $check = TRUE);
  $content .= '

';
  $content .= '
' . l(format_interval((time() - $node->created), 1, NULL), 'node/'. $node->nid) . ' назад
';
  $content .= '
';
  $content .= '
';
  return $content;
}

The code above displays a CCK field (field_photo), but what happens if the user has an empty "field_photo"?
Would the following code work?

if ($profile->field_photo == TRUE) {
  $content .= l($ava, 'user/' . $node->uid, array('attributes' => array('title' => $profile->title, 'class' => 'micro'), 'html' => 'true'));
}
else {
  $noava = theme_imagecache('microblog', 'sites/default/files/imagecache/user_block_small/imagefield_default_images/no_photo.png');
}


texts:
We are just trying to gain a deeper understanding of Drupal forms and how to manipulate and render them as needed.

We have a module installed which allows uses to edit and create content through a form.  The module renders the form on its own edit/create page.  We would like to render the edit/create forms on a different page with other content.

Below are a few functions which we believe render the forms. (if not which function should we be looking for??)

/**
 * Page callback for creating a customer profile of a given type.
 */
function commerce_addressbook_profile_create($account, $profile_type) {
  // Add the breadcrumb for the form's location.
  commerce_addressbook_set_breadcrumb($account, $profile_type);

  $profile = commerce_customer_profile_new($profile_type, $account->uid);
  // The submit handler needs an indication that the profile was just added.
  // The regular is_new property gets unset after save is complete.
  $profile->_is_new = TRUE;
  module_load_include('inc', 'commerce_customer', 'includes/commerce_customer_profile.forms');
  return drupal_get_form('commerce_addressbook_customer_profile_form', $profile);
}

/**
 * Page callback for editing a customer profile.
 */
function commerce_addressbook_profile_options_edit($account, $customer_profile) {
  // Add the breadcrumb for the form's location.
  commerce_addressbook_set_breadcrumb($account, $customer_profile->type);

  // If the profile is referenced by an order, make sure it gets duplicated.
  $profile = clone($customer_profile);
  if (!commerce_customer_profile_can_delete($customer_profile)) {
    $profile->previous_id = $profile->profile_id;
    unset($profile->profile_id);
    unset($profile->revision_id);
    $profile->is_new = TRUE;
  }
  module_load_include('inc', 'commerce_customer', 'includes/commerce_customer_profile.forms');
  return drupal_get_form('commerce_addressbook_customer_profile_form', $profile);
}

What is the process for calling these functions (if they are the ones we are looking for) into a TPL page?

EASY TO READ COMMENTS:
I have added the follow to template.php within my theme directory

function THEME_preprocess_page(&$variables){
    module_load_include('inc', 'commerce_addressbook', 'includes/commerce_addressbook.user');
    $variables['profile_form'] = commerce_addressbook_profile_options_edit($account, $customer_profile);
}

I have also included the following with a page tpl file.

<?php print render($profile_form); ?>

This results in the page returning a 500 error. (commenting out the variables line allows the page to load.)


texts:
My question is when i  browse  my admin site www.example.com/user a simple login page will appear.

Here in this login form there is no option for forget password .so I need option to request new password and new password can be send through email.


texts: How to show only published node in Drupal Facets (Facet API + Search API)?

texts: I have some taxonomies and node belongs to these when i have created search with facet then all node displaying(publishe + unpublish). i want only published node will show.


texts: How can i display child terms under parent terms and assigned articles using entity field query?

texts:
Hi i have one content type with  two vocabulary term references one is called category and terms is A,B,C like the 2nd one resources it contains parent with child terms like below hierarchy

Resource 1

    Subsection 1
    Subsection 2
    Subsection 3
    Subsection 4

Resource 2
Resource 3
Resource 4

so i want to display articles based on first taxonomy  category then 2nd taxonomy resources related items using entity field query below hierarchy

Resource 1

    Subsection 1

        Article 1
        Article 2

    Subsection 2
    Subsection 3
    Subsection 4

Resource 2
Resource 3
Resource 4

below is my code for display only 1st taxonomy based articles fetching but i need to display both cases please help.

        <?php
        $vocab = taxonomy_vocabulary_machine_name_load('resource_category');
        $trees = taxonomy_get_tree($vocab->vid);
        $array_tree = array();
        $array_tree1 = array();
        foreach($trees as $tree)
        {
            if($tree->depth == 0)
            array_push($array_tree,$tree->tid);
        }
        $i = 0;

        foreach($trees as $tree)
        {
            foreach($tree->parents as $parent)
            {
                if($parent != 0)
                {
                    $array_tree1[$parent][$i]=$tree->tid;
                    $i++;

                }
                //~ if(array_search($tree->tid,$array_tree))
                //~ array_push($array_tree1,$tree->tid);
            }

        }
?>

<?php
foreach($trees as $tree)
{
    if($tree->depth == 0) {
    echo '
'.$tree->name;
    if(count($array_tree1[$tree->tid]))
    echo '
';
            foreach($array_tree1[$tree->tid] as $sub)
            {
                echo '
'.$sub.'
';
                $query_resources = new EntityFieldQuery();
                $query_resources->entityCondition('entity_type', 'node')
                        ->entityCondition('bundle', 'resouces')
                        ->propertyCondition('status', NODE_PUBLISHED)
                        ->fieldCondition('field_resource_category', 'tid', '21')
                        ->fieldCondition('field_resources_subcategory');
                $result_resources = $query_resources->execute();
                if (isset($result_resources['node'])) {
                    $news_items_resources = array_keys($result_resources['node']);
                    $news_items_res = entity_load('node', $news_items_resources);
                        //echo '
';print_r($news_items_res); echo '
';
                } else {
                    echo '
No Resources
';
                }
                    }
            echo '
';
            echo '
';
        }
}

?>


texts:
I have a block created with Views that I want to display in a node where "PHP filter" is enabled. How can I display the content of that block?

All the examples I can find seem to be for Drupal 6.


texts:
i want to display a node (from a menu callback), but when i do this:

echo node_view(node_load($_POST['classid']));

it displays the node without the page template. How do show the entire node, just like someone navigated to '/node/xxx'.

by the way, i can't just redirect to 'node/xxxx' because i need to leave the url without any parameter (stupid requirement by employers)


texts: {{ directory }} not available in parts of menu--main.html.twig

texts:
Printing {{ directory }} at the start of the file works fine. But a bit further it's no longer availble:

{% import _self as menus %}

{#
  We call a macro which calls itself to render the full tree.
  @see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level) %}
    **{{ directory }} {# THIS WORKS #}**
    {% import _self as menus %}
    {% if items %}
        {% if menu_level == 0 %}

        {% else %}

        {% endif %}
        {% for item in items %}

                **{{ directory }} {# THIS DOESN'T WORK #}**

                {{ item.title }}

        {% endfor %}

    {% endif %}
{% endmacro %}

Any idea why this happens and how to fix it?


texts: How best to send mail with server-generated attachments?

texts:
I've got a situation where I want to have some server-side code create a document (pdf, fwiw) and mail it to someone via drupal_mail and Mime Mail.  I've got all the appropriate modules installed, and it's working.  My problem lies in the permissions that are needed to make this happen: Mime Mail says that you must either put the files in the public webspace, or enable the "send arbitrary files" permission, which they properly note as a possible security matter.

Since the files are temporary and somewhat private, I'm creating them in temporary://, rather than leaving them visible in webspace where someone could potentially guess their names and find them in a browser.  (I'm deleting them after the message is queued, but still...)  This works, but it means that I need to enable the "send arbitrary files" permission for anonymous users, since it's the server that's doing the sending. This, of course, seems even worse than enabling permission for authenticated users, or some special class of user.  Blurgh.

I can kinda talk myself into thinking that it's not that bad -- the server is the only entity that can send mail in my system, and so maybe enabling this permission might be ok.  But I then think I'm kidding myself, but then I think that there aren't any alternatives.  Any suggestions out there?  Thanks!


texts:
How can I render a Youtube field to get the full code for embedding?

field_view_field('node', $o, 'field_testvideo', $display)

What are the settings for $display?


texts:
A error after theming the user registration.

Code i have use in template.php

<?php
function ViaGo_theme() {
$items = array();

$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'viago') . '/templates',
'template' => 'user-login',
 );
$items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'viago') . '/templates',
'template' => 'user-register-form',
);
$items['user_pass'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'viago') . '/templates',
'template' => 'user-pass',
);

return $items;
}
 ?>

and this is the code for user-register-form.tpl.php:

Registreren

   <?php print drupal_render_children($form) ?>

And now i have a error in de theme.inc, who now a solution on my problem ?


texts: Is drupal safe against brute force login attacks?

texts:
A brute-force attack is an attempt to gain unauthorized access to a website by continually generating and inputting various combinations of a password. This task is usually done by automation software (a "bot") which looks for success or failure messages and keeps trying new passwords until it gets a success message.

Is Drupal 7 safe against it  by default?
what is more secure configuration for it ?
Which module can help me for more secure sign in?


texts: Randomize the result of a database query

texts:
I'm executing a query for which I want to randomize the results.

I tried with $res=db_query("SELECT DISTINCT nid FROM content_type_event ORDER BY RANDOM()"),          but this doesn't work.


texts:
A view returns an event, which occurs on the current day, in a block.
If there is no current event in the database (empty result), a second view is started, which then outputs events from the past.

It is working, when I am logged in. As long as I am logged in, I see correct results, even in the view preview.

If I look at the next day as anonymous user, I don't see the current event; the block displays the view result of the previous day.
Only with a registration attempt the output is updated, no matter whether I logged in, or a registration attempt is started.

In the views I have changed under -> ADVANCED -> cache: „tag based" to "time-based" with duration of 1 hour for query results and output format.

Unfortunately, the result is the same: the output block is not updated according to the new day.
Now I have deactivated the data caching of the view module, in the hope that tomorrow the display is now updated independently.

If this does not work, only to log in once the day to force an update?

Admin/performance:

Modules:

views/settings/advanced:

The View:

The View (extended)


texts: Start page count from 1 with views pager

texts:
Is there a way to start the page count from 1 instead of 0 using views pager? Maybe using aliases or some module?

By default, the first page is displayed with the URL parameter ?page=0, the second page with ?page=1 and so on. The pagination works good, but in my opinion it would be more coherent having the page one for the url with the parameter ?page=1, the page 2 with ?page=2, etc.

I found a similar question here, but it's about Drupal 7 and I'm on Drupal 8:
Views pager - start paging from 1

Another discussion here: https://www.drupal.org/node/1818040, but without a solution.


texts: Which is more performant: entity_metadata_wrapper or field_get_items?

texts:
To get values from entities, there are two ways:

Use field_get_items and get the value of a field
Use entity_metadata_wrapper and get the value of a field

Although entity_metadata_wrapper abstracts away the language differences, its API is still awkward sometimes, especially when using PHP 5.3. For example, getting the value of a long text field usually goes this route:

$field = $wrapper->field->value();
print $field['safe_value'];

Fortunately, PHP 5.4 supports this syntax: print $wrapper->field->value()['safe_value'];.

But my question is more concerned about performance. How do they both work? Do they query the database every time they request a value? Does entity_metadata_wrapper requests everything at once? (Making field_get_item more suited to single-value-retrievals.)

I'm not brave enough to dive deep into Drupal source.


texts: How can I serve a "410 Gone" HTTP status AND redirect my removed content?

texts:
I have a load of content that is gone (don't ask). I would like to tell Google and other search engines that this resource is gone, please don't try to index it. This is what HTTP status code 410 looks good for.

This is great for search robots, but if it's a real person accessing the page, I'd rather they were redirected to the new content.

Luckily, all the gone URLs match a pattern.

Is it possible to have all those handled by issueing a 410, and a redirect of some sort?

(I worry that permanent redirects might affect SEO too?)

Put another way: what I want to say is "That content is gone, you should not link to it. There's new content here:..."

[EDIT: to express why this is Drupal related]

Drupal is my CMS. With any generic website I would find my own solution to present a page and the correct header. With Drupal there's usually "a module for that", sometimes an elegant way to solve a common problem, and sometimes a hideously inefficient way to square a circle known as "the Drupal Way" [joke].

Drupal has an in-built system for 404s that works great. You can set a page, and because it's got a url you can use the block module to put other useful stuff on it, e.g. a View.

So there's 2 questions:

Does Drupal (or a reliably contrib'ed module) have a way to issue 410s akin to the 404 system?
Does Drupal have a 302/301 redirect system that can work with path patterns (i.e. separate from node as these dead pages were from another module that has been removed)


texts:
I want a node that the user can edit the published setting on. (Via publish_content)

It should be unpublished by default 4 months after being published, but paused not reset when unpublished.

Also, there should be a cck field allowing the user to alter the time published beforehand but this should not be editable if the content has already been published and is in delay (Or unpublished and paused).

I've been looking at rules since this seems to be a pretty complex task, but I'm not exactly sure how to go about it and I'm new to rules.

After the initial (4 month) delay is over the user should be allowed to start this whole thing again.


texts: Users without "administer nodes" see a limited view

texts:
I'm attempting to create a view showing all the nodes that a user is referenced in (via a CCK user reference field in a multigroup). Because they are multigroups, a user may be referenced multiple times within a single node and within the same field. I have a view working that displays each occurrence properly (and contains multiple rows per node if need be). Everything looks great when an admin loads the view (or anyone with "administer nodes" permission). However, when someone without the "administer nodes" permission loads the view, it gets limited to only 1 row per node, even if the user is referenced several times.

The users have full access to view all the nodes listed in the view, and all the nodes are published.

I've been troubleshooting this for several hours and haven't gotten anywhere besides realizing that "administer nodes" is the issue (which I obviously don't want to give that permission to normal users).

Anyone know why users without "administer nodes" permission only see a limited view??

I'm on Drupal 6 using Views 6.x-2.16.


texts: How to save the definition of an entity?

texts:
I am trying to figure out if there is a difference between saving an instance of an entity and saving the definition of an entity.

My use case is this:  I wrote a small module that defines an entity, which I then used in other code on my site.  All of this worked just fine, and I thought that once I had created some instances of my entity, and that those instances were stored in my database, I could then disable the little module that defined my entity.  I thought, in other words, that defining an entity would be like defining a Content Type, and that once you had done so the new entity, like a new Content Type, would "stick around".

That, however, is not how things work.  If I disable the little module that defines the new entity, that entity disappears from my system, and the code that uses that entity fails.  Re-enabling the little entity-defining module returns everything to normal and the site works again.

I think I may have missed a step here [entity_save?] but find nothing in the documentation that discusses saving the definition of a programatically defined entity.

Two more things.  First, I have noticed that the "model" module, which provides a template for creating your own entities, exhibits the same behavior that my little module did:  if I disable that module, the entities that I used it to define vanish from my system.  I have also noticed that the Entity Construction Kit [ECK] creates, in addition to the base table, two additional tables, one of which, eck_bundles, looks like it has entity properties.  I have not been willing to disable the ECK, though, because the documentation says that Drupal needs it.

Another way of posing my question would be this:  "Do you have to keep the code that defines your entity in your system, or is there some way of storing the entity definition for subsequent use?"

I am running Drupal 7.39


texts: Why is a ISO:8601 date within a time tag converted to zeroes?

texts:
I've been attaching Timeago script to my themes and it requires dates to be formatted like this.

<time class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</time>

In a view, I have one field set to rewrite as follows.

<time class="timeago" datetime="{{ Created_1 }}">{{ Created }}</time>

The previous version of the script made use of the Unix Epoch time format (U), but the most recent one available shifted to ISO:8601 (c). I found out today after updating the script that the view is converting the ISO dates within every time tag into double zeros (00).

The resulting html will be like this in both of the admin and site themes:

 <time class="timeago" datetime="00">

For some reason I can get the ISO date to print outside of the time tag but not within the datetime portion of the time tag.

How do I stop it from doing that?

My reasoning for using time ago is that it is more linguistically accurate than the format supplied by Drupal. For example, check the difference in formats between Arabic and English. Is something like this achievable solely through the translation interface? It would be nice to know if it is.


texts: View of users-profile who had flagged me "subscribe"

texts:
Using Drupal7 Views 3 and Flag 3, I have been able to display users-profile I have flagged "subscribe" but no luck to display users-profiles that flagged me "subscribe".

Below is what I currently have but the result is still displaying users that the given url has flagged.

I used filter"user ID from url" and for relationships, I used "flags:subscribe(by any user) and checked/unchecked include only flagged content.

Please help.


texts:
I have encountered a weird problem in Drupal 6 in the recent days: I can log in as admin but none of the mysite.com/admin/* links work from GUI.

I still can use drush to enable and disable modules and do other administrative tasks but can not do the same from the admin menu.

None of the other aspects of the site are affected. I cleared all cache, updated the database, performed cron (using drush), and restarted all servers. Alas, no effect. The log messages are not helpful either.  I'm really perplexed and appreciate your help.


texts:
I have view that displays a table of node for the current user.

I am confused as to how i can provide the functionality to bulk update certain values.

For example:

I have table of nodes (custom content type=List) and that content type has a custom field called list_status.

I want to update the value of the list_status for all the selected nodes.

I looked at VBO (Views Bulk Operation) to do this, i managed to do it with "Modify Entity Value" setting but the UI/UX i get with this is not what i desire. It takes me to a new page to select the value.

What i need to do is is run this action on a button click. I would really appreciate if some one can please help me figure this out?

I felt, i would only be able to accomplish this by doing something custom with my own module but if i am right, then a starting point for this would also be just as much appreciated.


texts: Cant remove description field for new taxonomy terms

texts:
Ive created a new taxonomy vocabulary. For some reason I cant remove the description field for the terms, but I only need the title field.

Is this a bug or impossible to do or are the settings hidden somewhere strange? Thanks


texts:
I'd like to add a 'Year of birth' field to the build-in registration form. Therefore, I created the Integer field 'Year of birth' at Administration > Configuration > People > Account settings.

I set the minimum value to 1900 and the maximum value to 2013. But, instead of '2013', I'd like to use the token [site-date-yyyy], so that I don't have to change the maximum value every year. Unfortunately, only integers are accepted. How can I use a token?


texts:
after a user purchases a certain role (i use UC and a rule to do so) the main menu is not updated automatically. The user had access to everything that belongs to the new role, but the menu only gets updated when i manually clear the cache on the site.
In searching for a solution i found this has to do with menu caching.
I don't use drush or devel and need a solution that suits a production site. Is it best to completely disable menu caching? And how do i do that? Is there a module for that?
Thanx,
Cas


texts: Views Data Export - Individual records for each file path iteration

texts:
I'm exporting data through Drupal 7 Views 3 data export to CSV file. I've worked out most of the kinks, but cannot find a solution to the following:

CSV file output contains iterations/rows of each node for every image file referenced (3 images for a node = 3 iterations/rows. What I'm aiming for is an image array/list (simple separator) contained in a single node record. I can't see any multiple results options for the field settings and I've got aggregate/group results together selected, but there's no other options (e.g to group by entity ID like for term references)

I'm using a File Usage:File relationship and Field - File: File(Image URL) path to generate the image URLs. I'm aggregating on NID, Image URL among others. I get the feeling the view needs to process the results before it aggregates. Is this the case?

I can export my view if that helps anyone, just say the word.

Many thanks


texts:
I am wondering if there is a way to have a menu under another menu in Drupal 7. Let's say I have a new menu called Blah and I want it to appear under the main menu item Top.

So I would end up with

Main Menu

|- Top
|---Blah Menu
|------ Blah Menu Item


texts: Trigger an event when file is upload on managed_file field

texts:
I'm trying to trigger an javascript function when a user select an image for a managed_file field and click on the upload button, not the submit one.Except that in Drupal 7, managed_filr field do not accept ajax argument, I don't have any idea on how to solve my problem.
Thanks you in advance.


texts: How can a form remember the selected tab after submit?

texts:
I'm using vertical tabs in a form, and I keep all the values with $form_state->setRebuild(true);. In this way, the user can change some of the submitted values.

I would like to keep the selected tab active as well. How can I achieve this?

If there aren't other solutions, I will use JavaScript to manually select the tab after the form is reloaded.


texts: i am currently working on a custom theme and i would like to know if it is possible to create a custom page which would include some php and would be visible after enabling the theme? or is it maybe better to create pages using drupal front end way and then packing it in installation profile ?


texts: How do I switch a node's view mode for AJAX calls?

texts: I've programmatically created a new view mode called ajax.  Is there any way to force a node page to use that view mode if I'm making an AJAX call?  I know how to switch page and node templates when it's an AJAX call in template.php, but it's not quite the same thing.


texts: How do I import a database through a Drush(PHP) script?

texts:
I am trying to write a Drush script locally to speed up some repetitive tasks. I am running in to issues importing a database through the script. I have tried using drush_invoke and drush_invoke_process to run the equivalent of drush sql-cli < C:/path/to/mysql.sql.

I have tried several different variations with the $commandline_args and $commandline_arguments with no luck and Google has not been helping me much.

Does anyone have the correct syntax for this? I would also be fine with another method that works. I would prefer one that allows for a user input path to the SQL file but hard coded would work for now.

EDIT: I am using drush scr to run the script. Just in case it makes a difference.

EDIT 2: The accepted answer from greg_1_anderson works great. To allow for using the path to the file as an argument I found that drupal_get_option works. Just add the argument --arg_name=arg_value like drush scr script.php --file=path/to/file. Then call the arg in the script file.

Full solution:

$file = drush_get_option('file');
$options = array(
  'file' => $file,
  'file-delete' => FALSE,
  'strict' => FALSE,
);
drush_invoke_process($self, 'sql-query', array(), $options);


texts: How to display data collected in a form on a page templated in module's tpl file?

texts:
I'm new in the use of Drupal and I have some troubles with the module I'm writing.
This module generates a form that writes datas in some tables. It works fine, the datas are correctly writen in the database.

My module.module file contains the following functions :

function myform_xml_menu()

function myform_xml_form($form, &$form_state)

function myform_xml_form_submit($form, &$form_state)

The big question is : how to display the submitted datas ?

I've already tryed writing a second module called "Display" :

<?php

function display_menu(){
$items['display'] = array(
    'title' => 'Display',
    'page callback' => 'display_contents',
    'access callback' => TRUE
);

return $items;
}

function display_contents(){

$query = db_select('form_xml', 'f');
$result = $query
        ->fields('f')
        ->execute()
        ->fetchAll();

$output = '
Id	Name	Description
';

foreach($result as $key){
    $output .= '
';
    $output .= ''.$key->id.'	';
    $output .= ''.$key->name.'	';
    $output .= ''.$key->description.'	';
    $output .= '
';
}
$output .= '
';

return $output;
}

It adds a menu item and display my results correctly too. But I feel making it wrong or unproperly...
I've read many docs speaking about displaying module's results in blocks or pages.

How can I embed my results in a Drupal page in order to be able to manage its display using a .tpl file ?


texts: D7: Blog post set to language but all the time visible

texts:
I created to blog post, one in english, on in german.
But if I launch set a menu link with the link "http://www.drupalsite.com/en/blog", I still see all blog posts.

How to change that it only display posts in the defined language?

Thanks


texts: How to query the last 5 nodes of multiple content types?

texts:
I want to query last 5 nodes of multiple content types, say, typeA, typeB, typeC, typeD.

It was originally only one content type, and I did it using EntityFieldQuery:

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'typeA')
  ->propertyCondition('status', 1)
  ->propertyOrderBy('created', 'DESC')
  ->range(0, 5);

$result = $query->execute();

But now I need to include 3 other content types to the list.

Is there any way to expend this query to include the last 5 nodes of the other 3 content types as well. So that the result will have 5 last nodes from all 4 content types, altogether 20 nodes.

Or should I do it with 4 individual queries?


texts: Cannot figure out where the tmp folder is to add the .htaccess file per http://drupal.org/SA-CORE-2013-003

texts:
That doesn't make any sense to me. I do not have a tmp folder anywhere outside the root. I cannot find the /tmp folder supposedly outside the folder where my Drupal instance is located. Well, let me correct that. I found one, but placing the recommended .htaccess file in it didn't solve the error message. It didn't seem to be the correct tmp directory. Maybe I don't fully understand where outside the root dir is at? Isn't it the directory above where the installation is at? Is it in the html folder, the sites folder, or above the html folder?

Will the instructions in http://drupal.org/SA-CORE-2013-003 work if I create a tmp folder in the html folder? Where exactly do I create the tmp directory?


texts: node and taxonomy module Update #7006 and #7005 problem

texts:
I upgrade my Drupal6 to Drupal7.

When everything was done.

The error messages as below came out.

The following updates returned messages

node module
Update #7006

Failed: DatabaseSchemaObjectExistsException: Table field_data_body already exists. in DatabaseSchema->createTable() (line 657 of /home/mysite/domains/site.com/public_html/includes/database/schema.inc).

taxonomy module
Update #7005

Failed: DatabaseSchemaObjectExistsException: Table taxonomy_update_7005 already exists. in DatabaseSchema->createTable() (line 657 of /home/mysite/domains/site.com/public_html/includes/database/schema.inc).

How should I fix it?

I have reupdate the module but same problems.


texts: hook_theme, custom data, passing to custom TPL file

texts:
I am having trouble passing custom data through theme() to a custom callback and passing the data through to a tpl file. Here is my code:

hook_theme:

function satb_schedule_theme() {
  return array(
    'satb_schedule_brackets' => array(
      'render element' => 'bracket',
      'variables' => array('bracket' => array()),
      'template' => 'satb_schedule_brackets',
      'path' => drupal_get_path('module', 'satb_schedule') . '/templates',
    )
  );
}

hook_menu item:

$items['tournaments/%/%/schedule/winner-bracket'] = array(
    'title' => 'Winner Bracket',
    'description' => 'View the winner brackets for this tournament.',
    'page callback' => 'satb_schedule_generate_bracket',
    'page arguments' => array(1, 2, '0'),
    'weight' => -16,
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array('view tournament brackets'),
  );

hook_menu item callback (satb_schedule_generate_bracket):

function satb_schedule_generate_bracket($nid, $product_id, $bracket_type) {
  $schedule = new SATBScheduleDisplay(array('nid' => $nid, 'product_id' => $product_id));
  return $schedule->getTournamentBracket($bracket_type);
}

This function generates an array of data. Inside of the method, data is gathered and returned through theme(), like so:

$output = theme('satb_schedule_brackets', array('bracket' => $brackets));
return $output;

In the template.php, I have this to modify and add variables for the template:

function satb_preprocess_satb_schedule_brackets($variables) {
  $brackets = $variables['bracket'];

  foreach($brackets as $key => $round) {
    switch ($key) {
      case 3:
        $classes = array('round', 'quarterfinal');
        $round_title = t('Quarter Finals');
        break;
      case 2:
        $classes = array('round', 'semifinal');
        $round_title = t('Semi-Finals');
        break;
      case 1:
        $classes = array('round', 'final');
        $round_title = t('Final');
        break;
      default:
        $classes = array('round');
        $round_title = t('Round @round_number', array('@round_number' => $key));
        break;
    }

    $variables['bracket'][$key]['data'] = array('classes' => implode(' ', $classes), 'round-title' => $round_title);
  }

  $vars['bracket'] = $variables['bracket'];
  $vars['tournament_title'] = 'Just a test';
  return $vars;
}

My custom tpl is loaded (I can see the static HTML in there as a test and print static vars) however, my modifications don't seem to get passed to the template.

For example, if I do print $tournament_name;, its null. If I do print $bracket['tournament_title']- it appears, but I don't want to access variables like that because that's messy, and, it should respect the vars I am adding to the vars array.

What am I missing here? The classes and titles I am adding in the preprocess are also missing in the $bracket element in the TPL. The $vars has them, but the TPL does not.


texts:
I have composer.jon to require

"acquia/lightning": "2.1.3",

This installs Drupal core 8.3.3. Can I change this to Drupal core 8.3.2 or does Lightning force you to use the Drupal version its packaged with?

I updated this post after fixing the problem. I changed the composer.json file and specified what drupal core version to use like this.

    "acquia/lightning": "2.1.3",
    "drupal/core": "8.3.2",


texts: Drupal : How to remove the  and  tag from content when using syntaxhighlighter

texts:
Used Version 7.14

I am using syntaxhighlighter  for my website. But when I insert some code samples it always producing output with more <p> and <br> also content in single line as well .

I am done just copy paste the code from zend studio editor inside the syntaxhighlighter tag

I've searched over many forums and druapl site itself, but nothing works for me. Please advise me on this

See the picture below  for more


texts:
I would like to use page level skins in my theme, for example.

If I make Colors widget for my skin where I can choose Red/Green/Blue colors and I choose Blue, the class blue is added to body tag.

As far as I know, I've set up Skiner properly, the above is working for regions, blocks etc, but when I set it for page, the class is not showing anywhere.

I appriciate any help, thank you!


texts: How to add facebook like/share button to every new text I post?

texts: I would like to add facebook like/share button to every new post on news site without doing it manually every single time I post new text. Similar question has already been answered, but I wonder if there is solution that doesn't include much code intervention, for example, is it possible to do it just with Facebook Like Button Module or something alike. Thanks in advance.


texts: Why is this property of the Cron service initialized in this manner?

texts:
I wish someone could help me understand this code statement found on the core cRON service (\Drupal\Core\Cron), especially in the constructor method for this class.

public function __construct(ModuleHandlerInterface $module_handler, LockBackendInterface $lock, QueueFactory $queue_factory, StateInterface $state, AccountSwitcherInterface $account_switcher, LoggerInterface $logger, QueueWorkerManagerInterface $queue_manager, TimeInterface $time = NULL) {
  // Omissis
  $this->time = $time ?: \Drupal::service('datetime.time');
}

What does this line do? Why isn't $this->time = $time; instead used?

The service is already injected using arguments.

class: Drupal\Core\Cron
arguments:
  - '@module_handler'
  - '@lock'
  - '@queue'
  - '@state'
  - '@account_switcher'
  - '@logger.channel.cron'
  - '@plugin.manager.queue_worker'
  - '@datetime.time'
lazy: true


texts: Problem with CCAvenue Module - Order not generated after successful transaction

texts:
I am using Drupal 8 module of CCAvenue.
For some reason I am not able to get it work, I have used both the modes - Test and Live.
Actually the issue is when I place an order and click on checkout page it redirects me to the CCAvenue test site, once on that test/live site of CCAvenue, I enter my card and other details, then it redirects me to my website but the order is not placed.
So why is the order not getting placed successfully even after successful transaction?


texts:
So I thought I had been pretty clever when in the code for a custom checkout pane, in a custom checkout page, I did this:

function checkout_pane_giftaid_pane_checkout_form($form, &$form_state, $checkout_pane, $order) {
  if($showPane==1){
    //show something awesome
  }
  else {
    $checkout_pages = commerce_checkout_pages();
    commerce_order_status_update($order,'checkout_payment');
    $url = 'checkout/'. $order->order_number  . '/' . $checkout_pages['gift-aid']['next_page'];
    drupal_goto($url);
  }
}

If showPane is equal to 1 it displays the Pane's content, if not it directs you to the next checkout page. This however has presented an issue because I have two custom checkout pages.

The result of this is if you are on 'custom page 2' and press 'Go Back' it goes back to the previous page ('custom page 1'), but if $showPane=0 on this page then the else statement means its set to forward. So a user hits 'go back' on 'custom page 2' and what they see, is this page reload (actually it has gone back to 'custom page 1' where it is told to go to the next page, 'custom page 2').

So my question is this: clearly I have not gone about 'skipping' custom checkout pages in the right way, how would I do it properly?


texts:
can Someone explain how can i make one field in Drupal 8 that can contain multiple fields in it... I am not allowed to use Paragraph module. I want to make it full programmatically, By the way i know how to make simple field in Drupal 8 but don't know how to set schema or form form dynamic field that can have multiple fields in it.
 For Example when we want to add some field in user or in node, we go to ~/fields/add-field and then select the field type, after in the field setting i want to have one form element that says add filed and the type of the field. and after saving setting, i will generate the field widget and formater depending on the field type selection that i made before.

Is there a solution for this problem (only programmatically)?