texts: Custom authentication provider returns 403 for _access: 'TRUE'

texts:
The Jenny module implements an API and needs to authenticate based on this header...

Authorization: Jenny 8675309

Here is my API route...

jenny.api.get:
  path: '/api/jenny'
  defaults:
    _controller: '\Drupal\jenny\Controller\ApiController::get'
  methods: [GET]
  requirements:
    _access: 'TRUE'

The API returns data for any type of user, but for some roles additional data is included.

Here is my implementation for AuthenticationProviderInterface...

public function applies(Request $request) {
  if ($header = $request->headers->get('Authorization')) {
    if(strpos($header, 'Jenny ') !== FALSE) {
      \Drupal::logger('jenny')->info('this applies');
      return TRUE;
    }
  }
  return FALSE;
}

public function authenticate(Request $request) {
  \Drupal::logger('jenny')->info('authenticate');
  return $this->entityTypeManager->getStorage('user')->load(1);
}

This example code authenticates the admin user whenever there is an Authorization: Jenny header. Obviously the real code implements the logic to authenticate the proper user.

Here's what shows up in the log...

uid  type            message
0    jenny           this applies
0    jenny           this applies
0    jenny           authenticate
1    jenny           this applies
1    jenny           this applies
1    jenny           this applies
1    accesss denied  /api/jenny

It shows the uid changing, so it suggests that my authentication provider is doing it's part, but for some reason it's still coming back 403 access denied even though the route is _access: 'TRUE'. A request for /api/jenny without an Authorization: Jenny header returns the expected data.

This makes no sense to me. Could someone please point out what I'm doing wrong or why this isn't working? Thanks.

Upon further review, this is happening on all routes if there is an Authorization: Jenny header, even though the authentication provider is returning the admin user.


texts: views exposed filter select list users with specific role

texts:
I created a content type coty1.

I have 2 user roles that can create that content type. role1 and role2.

1.How can I create view that one of the filter field is expose that allow me to choose just users that have role1 or role2 (not all the users of the site).

2.How can I create view that one of the filter field is expose that I can choose just users that realy created one or more from coty1 content type?

Thanks a lot.


texts: I need to upload an image to a term as well as to a node using BEHAT with Drupal API. How this can be possible?


texts:
I am trying to get a handle on Ctools ajax modals and I am reading a lot of tutorials. In one of the tutorials (on https://gist.github.com/mrconnerton/1979037), I see the following code:

// Create a blank node object here. You can also set values for your custom fields here as well.
$node = (object) array(
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => 'mytype',
'language' => LANGUAGE_NONE,
);

$form_state = array(
'title' => t('Add my content type'),
'ajax' => TRUE,
);

$form_state['build_info']['args'] = array($node);
// change this to your type node form
$output = ctools_modal_form_wrapper('mytype_node_form', $form_state);

I don't understand the function ctools_modal_wrapper. What exactly are the two parameters?

On the ctools API, it says they are $form_id, &$form_state but I'm not sure what

a) the form id is and where it comes from and

b) what a form state means? This might be a question on the forms API itself, and if so, please guide me to understand how this all works.


texts: Create a printable document from template

texts:
I am fairly new to Drupal. I have a Microsoft Word Document template and would like to allow users to fill in fields and insert an image and then print the document. I am not stuck on using the Word template if that is not feasible.

We have been using a document that is a fillable form. We fill out the fields and then have to add an image to the form in a particular position. I would like, if possible, to have Drupal do this. I would like it so a use goes to the site, fills out the information and uploads the image. Once that is done they would need to print the document and have it retain a specific layout.

Possible? Please point me in the right direction. I am using Drupal 7.x

thanks


texts: Multiple forms on one page - gather values

texts:
I am using the hook_form to create 2 different forms in a module file. Now it depends on what the URL parameters are, it can either display, one or the other or both.

Is there a function that picks up all form_states so i can gather values?


texts: How to remove JS from a page during preprocess D7

texts:
I'm trying to remove few JS files from one page, which will be called in an Iframe (so no TEMPLATE_js_alter possible because of the if condition).

This code below unset the JS but they are still loaded on the page. It's like I can't save the new list of JS.

Any ideas ?

 function theme_preprocess_page(&$variables) {
        $scripts = drupal_add_js();
        dsm($scripts);

        if(arg(0) == "account" && arg(1) == "reset"){
            foreach ($scripts as $key => $value) {
                $uri = strrpos($key, 'sites/all');
                if($uri !== FALSE){
                    unset($scripts[$key]);
                }
            }
            $variables['scripts'] = $scripts;
        }
    }


texts: How can I replace the "Add to cart" button with an "Ask about product" button, based on product property?

texts:
Let's say client wants button "Ask about" for chosen product instead of "Add to cart" (he requires personal contact for some products). It should be based on data from a specific product field, so he could choose for what products he requires personal contact. It would be also nice if that optional button would redirect user to webform, that would automatically contain name and attributes of chosen product. How can I approach this?

Added:
I can disable "add to cart" form, from hook_preprocess_node, or hook_node_view_alter, but I wonder if it can be ajaxified, so only if user will choose specific product, from configuration of attributes, the "add to cart" button, would disappear and "Ask about product" would appear. I also need to turn off possibility of adding that product to cart by forged POST requests. Anyone know how to do it?


texts: Redirect beating out URL path and creating redirect loop

texts:
Currently ran a bunch of updates on our site, and we're experiencing this issue:

Create nodea at /nodea
Change nodea's path to /nodeb

a redirect will be written added to nodeb: /nodea -> /nodeb

Create a new new node, and call it nodea, so the URL path then becomes /nodea for it
If you try to go to the new /nodea page, the redirect rule catches it first and sends you to /nodeb

I'm not sure what caused this, and it's a huge issue. (That example is, of course, just to show what's occurring; it's not the exact use case, but pretty close.)

Can anyone give me an idea on how to fix this? Or at least where to start looking?


texts: can we change block title using template_preprocess_block?

texts:
I am having a need to dynamically change the title of a block. Here is what I am trying but no avail.

function MYMODULE_preprocess_block(&$variables) {

  if ($variables['elements']['#id'] == "views_block__weekly_schedule_all_blocks_block_2") {

    //$variables['elements']['content']['#title']['#markup'] = "Foobar";

    //$variables['elements']['content']['#title'] = 'foibar';
  }
}

Any help is appreciated.


texts: Can view file list in IMCE but can't load files

texts:
I'm setting up a Drupal 7 multisite. Already have another site running with no problem on same server. I can access IMCE browser (see image below), and can upload but not insert images; clicking on image does nothing. When I hard code link to image into a text field, I get 404 'file not found' error.

Setup is standard:

/www/d7 [drupal core]

/www/multisite1 [symlink to ../d7]

/www/multisite2 [symlink to ../d7]

Within /www/d7, also standard setup:  sites/multisite1/files, etc. Everything else including Clean URLs is working correctly, and I've set all permissions per usual. I'm stumped, have tried various mod_rewrite directives and none have changed anything.  Any possibility there's some path corruption in database? Any other suggestions?


texts:
I am building a case tracker on top of Open Atrium. My case node has some custom fields, and the "Case" category is a hierarchical select taxonomy field. I have another field called level which is dynamic and expected to change when the value of hierarchical select field input changes with custom JavaScript.
It works fine, but when the hierarchical select makes an AJAX update of the node form, the custom Javascript code stops working. I checked the Firefox JS error console, and Drupal recent log, but I could not find any error. For some reasons the hierarchical select doesn't work well with my custom JavaScript code.

Do you have any suggestion on how to fix this problem?


texts: I would like it to show the hierarchy of menu's links. Testimonials and Company are under About us. How can I achieve this effect? Let me specify with an image:


texts: Meta tag module not visible under individual node

texts:
I have installed Drupal 8 on my local machine with Metatags module for SEO.

The global settings are available to edit under Configurations → Search and Metadata → Metatag but the Metatag tab is not visible when I edit individual articles.  I want to change the meta title and description for each article.


texts: Payment Method displays after Page Refresh

texts:
I am using uc_hotel booking module with Ubercart. When I add a hotel to cart and checkout it shows No Payment Required in Payment Method.

After Refreshing the Page it shows the credit card in payment method.

Why not it displaying the credit card option at first time when I click on Checkout.


texts: When to use custom nodes? How to display custom fields?

texts:
I am a newbie to Drupal.
I have a custom content type blog_post, with some custom fields, like subtitle.

I have the following two divs, which I want to render for this blog_post like that:

+--------------+--------------------------------+
| 9 Sept 2013  | Good weather on the West coast |
|    2013      |           (title)              |
|   (date)     | Winds are blowing hard in NY   |
|              |          (subtitle)            |
|              | According to the Department... |
|              |          (content)             |
+ -------------+--------------------------------+

My solution: amend node.tpl.php like that:

    <?php print $date; ?>

  <a href="<?php print $node_url;?>">
    <?php print $title; ?>

    <?php print $subtitle; ?>

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

How do I pull $subtitle from the database? Best way I found so far, looks somewhat ugly:

<?php
  print $field_subtitle[LANGUAGE_NONE][0]['value'];
?>


texts:
I have a month-view calendar block and would like to change months without page reload.
How can I achieve it?


texts: Sorting view results using contextual filters on Drupal 8

texts:
I created a views that filter nodes according taxonomy terms passed through contextual filters.

Node 1: term1, term2, term3
Node 2: term1, term6
Node 3: term1, term7

Everything is working good, expect i would like to display the number of term tid found in the node.
When i use the parameters term1+term7 (in contextual filters), i would like a result like this :

Node title 1: match 1
Node title 2: match 1
Node title 3: match 2

and then sort results by the matching terms.
How can i make it work with Views 3 in Drupal 8?
Many thanks.


texts: Select on which page a view has to be display

texts:
I am new to the Views module in Drupal 7. I enable the Taxonomy Term view and customize it a bit. For now the view is displayed in the default page of my theme in the main content region. But I would like this view to be displayed in a custom page defined by my theme on a particular region.
It seems to be an easy task but I can't figure how to do that.


texts: Daily and Weekly Newsletter using MailChimp or Mail()?

texts:
In my site I have 12K+ users and I want to send a daily and weekly newsletter. For this I want to use mailchimp module.  How to set a daily and weekly automatic newsletter?

Also is there any rules integration for mailchimp?

Or is there any better module for this?

Or should I use mail() function of PHP core?


texts: How do I use hook_views_query_alter() to re-write a query?

texts:
I have a very simple view that lists all the nodes, which shows the following query:

SELECT node.nid AS nid, node.title AS node_title, node.uid AS node_uid, node.created AS node_created, 'node' AS field_data_field_site_node_entity_type, 'node' AS field_data_field_status_node_entity_type
FROM
{node} node
WHERE (( (node.status = '1') AND (node.type IN  ('ticket')) ))
ORDER BY node_created DESC
LIMIT 50 OFFSET 0

I am trying to overwrite it with a custom database query to list only nodes of the user referenced in the URL and all his invitees. This is the code I am using.

function my_custom_module_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == "support" && $display_id == "page" ) {
    // Let's start collecting uids and put current page uid as the first member of array.
    $uids[] = arg(1);

    // Now let's collect all invitees of the page uid author and push into the same array.
   $query = db_select('invite', 'i')
     ->condition('i.uid', arg(1), '=')
     ->condition('i.status', '3', '=')
     ->fields('i', array('invitee'));
   $result = $query->execute();
   foreach ($result as $record) {
     $uids[] = $record->invitee;
   }

   // Now let's pull all the nodes of the inviter (page uid) and his invitees.
  $query = db_select('node', 'n')
     ->condition('n.type', 'ticket', '=')
     ->condition('n.status', '1', '=')
     ->condition('n.uid', $uids, 'IN')
     ->fields('n', array('nid', 'title', 'created'));
   $result = $query->execute();
   foreach ($result as $record) {
     dpm($record->nid.' | '.$record->title.' | '.$record->created);
   }

  }
}

dpm() shows all the correct nodes, but reading hook_views_query_alter() I still can't figure out how to make my view use this query.

How can I achieve this?


texts: How to properly name tpl file for webform-submission-navigation.tpl.php?

texts:
I am trying to theme the webform-submission-navigation.tpl.php template to add a link for a specific node but am having no success.

If I edit the main webform-submission-navigation.tpl.php file I can achieve what I require but for all of the webform nodes. What I want is to ONLY have this link for 1 specific webform (node 139).

What I have tried to do is name the file as follows, put them in the corresponding themes template folder and the reset cache but have no success:

webform--submission--navigation--139.tpl.php
webform-submission-navigation--node--139.tpl.php

Am I naming my file incorrectly?

Thanks for any help!


texts:
I have a service provider that does stuff(for lack of a better word).

Several functions in that service provider deal with a custom table in the database. Lets assume that in a function an id is passed, if said id doesn't exist I want to stop the process. Throwing out an exception would normally be the way to go, because this is an exceptional situation. The process cannot continue without that information.

I'm not exactly sure how to handle that in Drupal. I don't have that much experience with it.

I noticed that Symfony has an exception handler itself but I'm sure Drupal handles things differently.

Do I log the exception and kill the process? Just throw it out and hope for the best?


texts: Is the creator of a flag stored in the database?

texts: Is the uid of the user who created a specific flag stored in the database? Where is it stored?


texts: Cannot access data passed to $vars in theme function

texts:
I have got a problem in my template.php file, where I am trying to add data to $vars. I basically have a preprocess function for a view and in it I am trying to pass some extra info to $vars. However, the view is not getting those variables. This is what I have in my template.php file:

/**
  * Generic preprocess that is still working on D7
  */
function mytheme_preprocess_views_view_fields(&$vars) {
  if (isset($vars['view']->name)) {
    $function = __FUNCTION__ . '__' . $vars['view']->name . '__' . $vars['view']->current_display;
    if (function_exists($function)) {
     $function($vars);
    }
  }
}

/**
* preprocess variables for the badge owners view
*/
//function mytheme_preprocess_views_view__badge_owners (&$vars) {
function mytheme_preprocess_views_view_fields__badge_owners__page_1(&$vars) {
  $bid = $vars['view']->args[0];

  //Get the badge info
  $badge = db_query("
    SELECT ubb.bid, ubb.weight, ubb.name, ubb.image, ubb.href,
    ubb.unhideable, ubb.fixedweight, ubb.doesnotcounttolimit, ubb.tid
    FROM {user_badges_badges} ubb
    WHERE ubb.bid = :bid", array(
      ':bid' => $bid
  ))->fetchObject();

  $vars['bid'] = $bid;
  $vars['name'] = $badge->name;
  $vars['badge'] = theme('user_badge', array('badge' => $badge));
  $vars['an_extra_variable'] = 'hope this shows up in $vars';

  drupal_set_title(t('Badge: @badge_name', array('@badge_name' => $badge->name)));
}

This is what I have in my views-view--badge-owners.tpl.php file:

<?php
/**
* Variables available:
* - $css_name: A css-safe version of the view name.
* - $header: The view header
* - $footer: The view footer
* - $rows: The results of the view query, if any
* - $empty: The empty text to display if the view is empty
* - $pager: The pager next/prev links to display, if any
* - $exposed: Exposed widget form/info to display
* - $feed_icon: Feed icon to display, if any
* - $more: A link to view more, if any
* - $admin_links: A rendered list of administrative links
* - $admin_links_raw: A list of administrative links suitable for theme('links')
*
* @ingroup views_templates
*/
?>
<div class="view view-<?php print $css_name; ?> view-id-<?php print $name; ?> view-display-id-<?php print $display_id; ?> view-dom-id-<?php print $dom_id; ?>">
  <?php if (isset($admin_links)): ?>

      <?php print $admin_links; ?>

  <?php endif; ?>

<?php print $badge;?>

  <?php if ($exposed): ?>

      <?php print $exposed; ?>

  <?php endif; ?>

  <?php if ($attachment_before): ?>

      <?php print $attachment_before; ?>

  <?php endif; ?>

  <?php if ($rows): ?>

      <?php print $rows; ?>

  <?php elseif ($empty): ?>

      <?php print $empty; ?>

  <?php endif; ?>

  <?php if ($pager): ?>
    <?php print $pager; ?>
  <?php endif; ?>

  <?php if ($attachment_after): ?>

      <?php print $attachment_after; ?>

  <?php endif; ?>

  <?php if ($more): ?>
    <?php print $more; ?>
  <?php endif; ?>

  <?php if ($footer): ?>

      <?php print $footer; ?>

  <?php endif; ?>

  <?php if ($feed_icon): ?>

      <?php print $feed_icon; ?>

  <?php endif; ?>

 <?php /* class view */ ?>

Any help would be appreciated. Thanks.


texts: Should I activate feature modules on my dev site?

texts:
I have installed the features module on my dev site.  I am using it to store newly developed site functionality within new modules.  I then install the modules on my live site.

I was wondering, should I activate these modules on my dev site?  I am considering not doing this, because the functionality already exists on the dev site  Activating the new features modules (that are created by functions) seems a bit redundant and even a little dangerous.


texts: Reason for javascript disabled in drupal site?

texts:
I am using multisite module to maintain three sites. In that i have used "hierarchical_select" module for a form.

In one of my multisite this form is working great, But in the same form for other site, I am getting following error.

I have attached a screen shot of the error.

As it is using the same files, i am thinking that it should be an configuration issues. But i have checked thrice for all the configuration and unsuccessful.

Please help.

Thanks in advance for any help


texts: module_invoke to create user search block not working

texts:
I've done the following to create two search blocks:

$content_search = module_invoke('search', 'block_view', 'content_search');
$user_search = module_invoke('search', 'block_view', 'user_search');

And I then call the blocks as needed like so:

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

They render correctly and the content search works just fine, but running something through the user search block just searches content. I noticed that regardless of which block I use, they both go to the URL http://example.com/search/node/[search parameters]

(This is Drupal 7 BTW)


texts:
I'm creating workflow for my Drupal 7 site. On this site we installed Workbench, Workbench Access, Workbench Moderation and Workbench Media. I'm following this setting, but still having 2 issues with Workbench.

1) My drafts are not showing on "My Drafts" tab. It only show if I give the permission "Bypass content access control", which I dont want to do that.

2) I wanna hide "All Recent Content" on My Content tab. Currently, it how Logout page, and Thank you for creting an account page, which I dont wanna show these too.


texts: Get image from external URL without extension, save with new name and extension

texts:
This has been bugging me for a couple of weeks now and everything I've found on it so far talks about the mimetype or content headers to get the file extension.

The URL of my images is build like this:
"https://www.gravatar.com/avatar/4a042b8382a008d344561c8301509f3a?s=32&d=identicon&r=PG"
(not the URL I use, but it's build the same)

    $file_info = system_retrieve_file('https://www.gravatar.com/avatar/4a042b8382a008d344561c8301509f3a?s=32&d=identicon&r=PG', 'public://Vehicles/', TRUE);

This saves the image, but without extension. I also have no idea how to edit the name of the image without loading it up again. A dpm() from $file_info says the mime-type is 'application/octet-stream'.

If I manually add an extension to the saved image (.png or .jpg or whatever) it works for any extension.

So at this point I'm happy if I can add any extension to the image programmatically, get the file into file_managed and save it to a node field.

I'm using Drupal 7.


texts: Importing and using overlay from jquery_plugin module

texts:
I am trying (and failing) to use the jquery overlay plugin from the jquery_plugin module in Drupal 7.

I am using drupal_add_library() to add the plugin and drupal_add_js to add the code to generate the overlays.

The overlay trigger elements are area elements within a map.

Whenever I try and trigger the overlays, I get nothing - no errors or stacktraces or alerts, or messages in Firebug.

Here is the code - added directly into the page content.

drupal_add_library('jquery_plugin', 'overlay');
drupal_add_js('function($) {
    $(document).ready( function() {
        $(".overlayarea").overlay();
    });
}(jQuery); ','inline');

The map looks as the following:

<map name="globalmap">
    <area id="toronto" class="overlayarea" alt="Toronto" coords="94,195,6" shape="circle" rel="#tor_overlay" nohref />
    <area id="oxford" class="overlayarea" alt="Oxford" coords="576,147,6" shape="circle" rel="#oxf_overlay" nohref />
</map>


texts: About drupal_realpath() and PDF Formatter

texts:
The PDF Formatter module uses pdftohtml to transform PDF to HTML, and show information.

Changing the module code, it is possible to show images too, but the path used for the image in the HTML markup is wrong.

What can I do to fix it?

The code used by the module is the following.

// PDF to html formatter
case 'file_pdf_to_html_formatter':
  $pdftohtml_installed = pdf_formatter_pdftohtml_installed();
  foreach ($items as $delta => $item) {
    $html = '';
      $html = shell_exec('pdftohtml -q -stdout '.escapeshellarg(drupal_realpath($item['uri'])));
      // pdftohtml tends to generate too many non break spaces,
      // replace them with standard spaces
      $html = str_replace('&nbsp;',' ',$html);

      // pdftohtml generates a complete HTML file.
      // Drupal only waits for contents between the body tag
      $html = preg_replace('/.*<BODY[^>]*>(.*)<\/BODY>.*/si', '\\1', $html);
    }

    $element[$delta] = array('#markup' => $html);
  }
  break;

The output I get is the following.

<img src="/var/www/html/drupal/sites/default/files/imgtest.jpg" />


texts: Services 3: How to retrieve the current logged in user ID

texts:
I can get a list of all users by going to //endpoint/user/ but how do I return the current user?

My primary goal is to find out if the user is authenticated.


texts: How do you customise the Group subscription format

texts: I have assigned user profiles the field Group Type and set it to default as "is group type" so that users can subscribe to each others profiles. This is all fine but i would like to customise the link that allows the users to subscribe, i.e. the display format 'Group subscription'. It currently says: "Subscribe to group", "Unsubscribe from group" or "You are the group manager". Is it possible to customise this text?


texts:
I have view of teasers which one has united filed.

Is there a way to add "group by" by this field (join field table and group by the field) into sql query of view?


texts: How to use CiviCRM Entity for searches with Facet API

texts:
I am trying to create a faceted search on CiviCRM contacts. I have created an index using the Search API module and the Facet API module, but currently the CiviCRM contacts can only be indexed on their ids, not their names. Obviously, that ain't so useful for humans to read...

For example, config/search/search_api/index/MYINDEXNAME/fields brings up the CiviCRM contacts as a possible field, but the default value is integer, not fulltext or string.

I was suggested CiviCRM Entity as a fix for this, but I can't quite work out how it could solve the problem -- would be very grateful for any pointers, or any other ideas!


texts: Drupal 6 Ubercart - cancel/remove payment on order

texts:
I have an older Drupal 6 site using Ubercart. We were recently doing some work to the payment gateways and upon the completion of the work we neglected to remove the test payment gateway and there were several orders that were submitted for which no actual payment was ever made.

My question is - is there a way to remove the erroneous payment and set the order back to non-paid? I know I can change the status, but I need to adjust off the amount that was actually paid in this scenario instead of the customer having to go through the whole purchase again. My thought is that they can just log back in and re-complete their order with the test gateway payment having been removed.


texts: Help needed getting out of the habit of using TWIG as my Controller and Template files

texts:
I'm currently using TWIG to manipulate variables that have been created in Drupal 8. For example, I have a template that contains the following logic:

{% if item.field_main_images[0] %}
  {% if item.field_main_images[0]['#item'].entity.uri.value != "" and item.field_main_images[0]['#item'].entity.uri.value is not empty %}
    {% set main_image_uri = item.field_main_images[0]['#item'].entity.uri.value %}
    {% set main_image_zoom = main_image_uri | image_style('item_zoom') %}
  {% endif %}
{% endif %}

and

{% set featured_content = '' %}
{% if item.field_item_specification.0['#text'] is not empty %}
  {% set featured_content = item.field_item_specification %}
{% endif %}

Am I missing something here because i'm getting caught in spending a lot of time figuring out the data structures of the objects and manipulating the logic within my TWIG templates. I've got a feeling that I should be doing this in either a preprocess function on the content type or by some other means.

How could I perform this same procedure using the drupal framework i.e. symphony to create/manipulate the variables before the use of a twig template.

Can anyone shed some light on this?

Thanks in advance.


texts: Drupal Commerce address validation and/or separate house number field

texts:
Drupal Commerce uses Address Field for its billing information. Street addresses are implemented as Address 1 and Address 2 lines. No other fields will be added to the module, since they want to keep it simple and follow the xNAL standard.

So how are people doing validation of user input? Specifically, how do you make sure they don't forget the housenumber? This happens, and it means extra work for the shop contacting the customer if it's noticed in time, otherwise an undeliverable package will be sent.

One solution would be a separate required field for house number, but I haven't seen a clean way of doing that (see e.g. this). Or perhaps dynamic validation of the Address field. So what are Drupal Commerce shops using? Any examples or recommended approaches?


texts: How to use Form API when the form callback is a method?

texts:
How can I use AClass::FormCallback() as $valid_callback on the code below?

class AClass {
  public function FormCallback() {
  }
}

$valid_callback = ?

drupal_get_form($valid_callback);


texts: pagination broken on custom theme's search system page

texts:
I do not have pagination on the system search page .../search*.

When I toggle off my custom theme I have pagination on the search-result.tpl.php page, I can see the $pager variable. But on my custom theme I cannot find that variable, it doesn't show up. I have checked hook_query_alter() throughout all of my site and I do not see any conflict. I checked the template.php file and there is no issue there. I will begin to remove everything, piece by piece to find out if I can find a solution.

No real code to show, and I would send you a stock search-results.tpl.php page, but the code block doesn't want to show it because <?php ?> is interspersed with html tags. It is something like:

if ($search_results) {  print t('search results');   print $pager; }

I simplified it because of the aformentioned issue, but this is essentially it - it is so minimal it is laughable and it works for any other theme, but mine. So I just copy the search-results.tpl.php file over to bartik, then do drush cc -v all and recheck and I can use xdebugger to see the $pager variable, but the same file with my custom theme I never get the $pager variable.


texts: How can I disable or hide warnings and errors shown in the backend?

texts:
Is there a way to disable or hide warnings and errors shown in the backend? For example when a user creates a node and some error occurs on the live page (image or helper class not found), then there is a big red box with around 25 lines of error message on each page in the backend.

For my editors who have to write 100 nodes a day it's very annoying.

Edit:

logging & error -> error messages is set to display NONE.


texts: Drupal 8 installation (bash) script. I want the latest stable v8 version each time. But how?

texts:
My Drupal 7 script utilised a make file which specified '7.x' as the Drupal version to install, drush make would fetch the correct core files.

My current Drupal 8 script uses git to clone and then checkout a version, eg. 8.1.0, and then renames the remotes as per the instructions on this page. However since this method downloads the entire Drupal project history, I end up with a huge project folder.

I work for an agency and we install Drupal for website projects, so our need is not for the latest dev builds, otherwise I image I would just use:

git clone --depth=1 [url to drupal.git]

I'm looking for a way to clone the latest stable (release) v8 branch, with no extra files. I could specify the zip on the release page, but this would mean updating the script upon each new release. I tried using Composer, but ended up with a much more complex than necessary folder structure.

Can someone help me with a way to get essentially a copy of the latest v8 .zip file via a script?

Thanks!


texts: How to render HTML into a variable programmatically

texts:
Let's assume you have a "product" node $node, and for some reason you want to render HTML from $node into a variable $html using a Twig template. I'm a bit desperate yet, what would you do?

Additional info 1: We are not in a controller, but in a simple class that is registered as a service.

Additional info 2: 4k4 's answer does work if I call my class from a controller. But as soon I call it from a Drupal Console command I get an Exception "The theme implementations may not be rendered until all modules are loaded."

Edit: The complete solution

Obviously not all modules are loaded if we call the service inside a Drupal Console command. The Theme Manager will honor this with the aforementioned exception, so we have to force load the modules:

\Drupal::moduleHandler()->loadAll(); // Load all modules if not loaded already

Now it's safe to call the renderPlain() method as suggested below:

$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$build = $view_builder->view($node, $view_mode, $langcode);
$html = \Drupal::service('renderer')->renderPlain($build);

Edit: But what about a full page?

If you intend to render not only the node content but a full page (from <html> to </html>) you have to have the kernel handle an appropriate sub-request .


texts: Before upgrading, do I need to upgrade the Views module to 6.3.x?

texts:
I'm going to update a site from Drupal 6 to Drupal 7. It uses the Views module version 6.x-2.

I would like to know if I need to upgrade the Views module to version 6.x-3 before moving to Drupal 7.


texts: path_set_alias() generates the wrong alias, and creates a 301 redirect to the desired alias's path

texts:
I'm creating a webform when organic groups are created and I'm trying to set an alias for it with hook_nodeapi(). It successfully creates the alias when the insert operation for the group is called after the webform has been created and associated to the group, but if you edit and update the group it does not update the alias with the code I have written. and a SQL error is displayed.

Here is the code that is called by hook_nodeapi() on insert and update operations:

// Webform
$nid = $node->field_webform_id[0]['value'];
$webform = db_fetch_object(db_query("SELECT count(src) as total FROM {url_alias} WHERE src = 'node/%d'", $nid));
if ($webform->total > 0) {
  db_query("DELETE FROM {url_alias} WHERE src LIKE 'node/%d'", $nid);
}
path_set_alias('node/'.$nid, 'local/'.$state.'/'.$county.'/submit-tip');

I'm getting the webform node ID from a CCK field on the group, checking if there are aliases set already for that node, and deleting them from the url_alias table. Then I'm using path_set_alias to recreate an alias (in this case it is the same as before).

The error message displayed when updating a group:

  user warning: Duplicate entry 'local/pa/adams/submit-tip-' for key
  'source_language' query: INSERT INTO path_redirect (source, redirect,
  query, fragment, language, type, last_used) VALUES
  ('local/pa/adams/submit-tip', 'node/209', '', '', '', 301, 1311098626)
  in
  /var/aegir/platforms/crimewatchpa-dev-v2011-07-12-15-42/includes/common.inc
  on line 3538.

Instead of creating local/pa/adams/submit-tip as an alias to node/209, it creates an alias submit-tip-0 (submit-tip already exists on another node). A 301 redirect is also created with the path: local/pa/adams/submit-tip to node/209.


texts:
Is there a way in Views Slideshow to make the pager to follow the slide? Here is the link of the sample slider that I require http://www.jssor.com/demos/content-slider.html
When you clicked the next/prev button, then the thumbnail follows with the main slider.


texts: What is the use of Drupal.settings.ajaxPageState object?

texts:
I am working on a Drupal site on which a functionality breaks because the value of Drupal.settings.ajaxPageState.js gets reset to an empty array instead of an object containing the list of js files.

So I want to know what exactly is the use of this ajaxPageState object


texts:
I copied the database and source code from my local to another server.
On my local I have a bootstrap sub theme set as default which works fine. On the other server (which has the exact same db settings and code) the theme being rendered is Garland despite being disabled and the admin section under appearance stating that my sub-theme is the active one.

When I checked the site after updating the server it had the correct css but when I reloaded the page it reverted back to garland but without any changes to the admin settings.

What are some good steps to take in terms of debugging this.


texts:
I have the following content types - Efforts, Objectives, Groups and the user.

Efforts and Objectives can be shared by both users and groups. A user/group can have multiple objectives and efforts and can also share the same objectives/efforts.

Is it possible by using node references ? or Is there any other way where I can implement this functionality in drupal ?


texts:
I think this is a pretty easy thing to do once you figure it out once, but I'm struggling to do the following:

I have a content type called YouTube video. It accepts a text field "URL" that is the full video URL (or alternatively just the ending video ID)

I want the displayed content to be an embedded video. How can I set the default embed code and then have a variable to swap for the ID?

Edit: Been poking all day, still can't figure this one out. I'm from a Wordpress background and this would be a simple ~3 minute addition to functions.php. Can someone point me in the right direction?


texts: Is there a good way to set available countries in Drupal Commerce shipping and billing?

texts:
On admin/commerce/customer-profiles/types/billing/fields/commerce_customer_address and
admin/commerce/customer-profiles/types/shipping/fields/commerce_customer_address one is supposed to select the available countries in a little box. This is not ideal. So I would like to do this programmatically (possibly with drush), is there already a quick solution for this or do I have to delve into this myself?


texts: How should I configure Drupal 8 to sort comments from newest to oldest, similarly to what the Comment Goodness module does in Drupal 7?


texts:
How I use hook_form_alter with multiple Content Type..

function custom_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'register_node_form' || 'session_node_form'){

  if(empty($form['field_event_ref']['und'][0]['nid']['#default_value']))
     {
    $form['field_event_ref']['und'][0]['nid']['#default_value'] = arg(3);
     }
    $form['field_event_ref']['und'][0]['nid']['#disabled'] = True;
     }
  }

I want Here to Get Both Of (Register) and (Session) Content type to be alter..


texts: What happens to the return array of hook_views_default_views after the function finishes?

texts:
hook_views_default_views returns an array of $views objects. Immediately after that function has finished, where does it send the $views object it returns?

Obviously that array is passed to another function where it's iterated over and something is done with the data. That's what I want to investigate - what views is doing with the data.

I checked views.module and other files and saw a lot of references to ctools functions, but then got a little lost.

What and where is the function that handles that return value?


texts: redirect to custom profile panel page of individual users

texts:
Ok As @Letharion rightly says, i need to rephrase my question. SO here it is:

I created a basic page and gave it an url alias as "Profile". This page is meant to be my profile page for users on my site. On this page there are 3 quick tabs,"My-Profile", "My-Content", "My-Flagged-Node". The "My-Profile" quicktab has a call back to a custom panel page "user-profile" which has the user name, user picture, and the user activity (created as a view with activity module), and the number of content created by the user. The "My-Content" has the content by the user. The "My-Flagged-Node" quick tab on clicking loads a view showing the flagged nodes by the user. I have created these views and these work properly. Now when a user goes to his relationship and clicks another user's picture then i want that the user is taken to the "Profile" page of this user (the user on which he clicked). I undersatnd this has to be done by passing arguments to views from panels and so on but i am not clear on that. While creating my view in the contextual filters and the relationships i added user id from url as a default value but this takes me to a blank screen or to the same user profile. I hope i am clear now on what i want. Some redirection rules and passing arguments.

Regards


texts: Problems displaying full article - teaser only

texts:
My problem is that when I manually define teaser and body of the article, only the teaser displays after clicking "Read more" (the text entered in "Body" section isn't visible in any case)
I've defined max lenght of teaser to high value (2000) because I would manually set part of article which is visible in teaser mode but I think it should not impact on displaying full body.


texts:
I am looking for a way to present the following to users. This will be a list of checkboxes:

[ ] Region 1 A
[ ] Region 1 B
[ ] Region 1 C
[ ] Region 1 D
[ ] Region 1 E
[ ] All of Region 1
[ ] Area 2
[ ] Area 3
[ ] Area 4

This would all be stored in the same field.

So there are two main things I want to be able to do:

1) When entering the data, the admin/user should be able to choose any of the options, but if the select "All of Region 1", it automatically selects all of the Region 1 choices along with the "All of Region 1" choice.

2) When site visitors are searching this field (through an exposed Views filter), if they choose to filter for "All of Region 1" they should get anyone who chose any one of the Region 1 areas as well as anyone who chose "All of Region 1".

One solution would be to just remove the "All of Region 1" option from the exposed filter.

Or have the "All of Region 1" option in the exposed filter also check all the region 1 options automatically.

Is this necessarily a hook_form_alter solution?


texts: An AJAX HTTP error ocurred. HTTP Result Code: 500 (while trying to rebuild content access perms)

texts:
I have installed a module that ask me everytime to rebuild content Access Permissions, but every time I try to do it, it shows me an error I do not have idea why is it happening. Please help

An AJAX HTTP error ocurred. HTTP Result Code:  500 Debugging information follows: Path: /batch?id=172&op=do Status Text: Service unavailable (with message)
Response Text:

Please check the image for more details


texts:
Having browsed through drupal.org with no results for D7, let ma ask the public: does anyone know of a Search module that would extend the search by taxonomy terms?
I have a very taxonomy-intensive site, where each taxonomy term has a rich description field, as well as its own term page. I want user to be able to find not only nodes but also taxonomy terms.


texts: Migrate d2d picture migration destination path incorrect

texts:
I'm in the process of building a migration module for a d6 to d7 migration using the d2d module.

I'm almost there, but one thing that's holding me back is the DrupalPicture6Migration. After trial and error, this is what I have (using the d2d documentation):

/* Register the picture migration */

$picture_arguments = $common_arguments + array(
  'machine_name' => 'abcdPicture',
  'description' => t('Import Drupal 6 picture files'),
  'default_uid' => 1,
  'source_dir' => '/',
  'destination_dir' => 'public://pictures',
);
Migration::registerMigration('DrupalPicture6Migration', $picture_arguments['machine_name'], $picture_arguments);
}

source_dir points to the correct location: /sites/default/files/userPictures.

I'd expect the migration to go like this:

'sites/default/files/userPictures/picture-1589309970.jpg  -> public://pictures/picture-1589309970.jpg.

But when I perform the migration, the path gets migrated over instead of the pictures. So I end up recieving this error:

'The specified file sites/default/files/userPictures/picture-1589309970.jpg could not be copied to public://pictures/sites/default/files/userPictures/picture-1589309970.jpg.

The entire path sites/default/files/userPictures/picture-xx.jpg is copied into the public://pictures directory.

I am reading up on using destination_file but am failing to make the connection on how I'd code this.

Thanks!


texts:
I'm trying to build an edit form for specific users.
For one type of user I want to hide password field for example

What I did is to create a module called profilechange.

Into profilechange.module I wrote this code :

function profilechange_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'user-profile-form') {
       hide($form['account']['pass']);
       hide($form['account']['current_pass_required_values']);
       hide($form['account']['current_pass']);
    }
}

So I enable the module and into my page--user--edit.tpl.php I've this code :

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

It displays the default edit form. But password fields are not hidden.

That's why I need your help, I don't know why it does not work even if I clear the cache


texts: Selecting more then one column when groupBy is present (db_select) - Drupal 8 added 'ONLY_FULL_GROUP_BY'

texts:
In my custom Drupal 8 plug-in I perform such query:

$select = db_select('my_table', 'e');
$select->addField('e', 'field1');

$select->condition('field3', 'NULL', '!=');
$select->condition('field4', array(11, 12, 31, 32, 33), 'IN');

$select->groupBy("e.field1");
$select->orderBy("e.field1");
$select->orderBy("e.field5");
$entries = $select->execute()->fetchAll(\PDO::FETCH_ASSOC);

And it works fine. It returns me all records grouped by field1 that meets the condition, orderered. But it returns only field1 column.

I wanted to get more columns, so I have added another $select->addField('e', 'field2'); just after first one:

$select = db_select('my_table', 'e');
$select->addField('e', 'field1');
$select->addField('e', 'field2');

$select->condition('field3', 'NULL', '!=');
$select->condition('field4', array(11, 12, 31, 32, 33), 'IN');

$select->groupBy("e.field1");
$select->orderBy("e.field1");
$select->orderBy("e.field5");
$entries = $select->execute()->fetchAll(\PDO::FETCH_ASSOC);

This time I get error:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1055 Użyto 'my_database.e.field2' bez umieszczenia w group by:

Which means "my_database.e.field2 has been used without putting in into group by". But I don't want to group by every column I select.

Unfortunatelly Drupal 8 added ONLY_FULL_GROUP_BY :(
Then, how can I use groupBy and select more then one column at the same time?


texts: How can I set some checkboxes to selected upon the first loading of the form?

texts:
I have a form with checkboxes.

$form['my_checkboxes'] = [
    '#type' => 'checkboxes',
    '#options' => ['1' => 'one', '2' => 'two', '3' => 'three'],
];

And for example, I want to option '1' is selected upon form was loaded.

Could you clarify me, how can I set some checkboxes to selected upon the first loading of the form ?

Unfortunately, I couldn't find the solution in the examples module.


texts: Why am I getting "Access Denied" on /user/login?

texts:
Not sure what happened with my Drupal site, but I can't log in :s

When I go to /user/login, /user, /?q=user, /admin, whatever I just get "Access Denied", never presented with a Login form. Server response is 403.

Drupal 6 site.


texts:
module_load_include('inc', 'node', 'node.pages');

$form_id = 'reviewer_rating_node_form';

global $user;
$rating_id = views_get_view_result('get_rating', 'default', $nid, $user->uid);

// Rating hasn't been created yet. Create one.
if (empty($rating_id)) {
    // add node properties
    $newRating = new StdClass;
    $newRating->type = 'reviewer_rating';
    $newRating->title = $user->name . "'s rating of " . $nid;
    $newRating->uid = $user->uid;
    $newRating->created = strtotime("now");
    $newRating->changed = strtotime("now");
    $newRating->status = 1;
    $newRating->comment = 0;
    $newRating->promote = 0;
    $newRating->moderate = 0;
    $newRating->sticky = 0;

    // add CCK field data
    $newRating->field_rating_application[0]['nid'] = $nid;
    $newRating->field_rating_reviewer[0]['uid'] = $user->uid;

    // save node
    node_save($newRating);
}

$rating_node = node_load($rating_id[0]->nid);

$output = drupal_get_form('reviewer_rating_node_form', $rating_node);
return $output;

This isn't working for me. If I dpm $rating_node it looks correct, but when I call drupal_get_form I get this error:

Fatal error: Cannot unset string offsets in includes\form.inc on line 498

If I log the $form variable at that line it's a string that starts with this:

Aform action="/devsite/node/423"  accept-charset="UTF-8" method="post" id="node-form" enctype="multipart/form-data">
<div>

That "A" instead of a "<" might be a clue. I have no idea.

Any suggestions on what I'm doing wrong here?


texts: Is there a way to not have Manage menu open by default?

texts: On mobile, our managage tab of our toolbar always opens by default, is there a way to stop this?


texts: How to add delete link for imported content type

texts:
For the content type which is imported by feature, there is no delete link for it, but we can delete them by going to the url /admin/structure/types/manage/YOUR_CONTENT_TYPE/delete

My question is how to make the delete link also available for the imported content type?


texts: How can I get the machine name of a taxonomy term knowing its tid?

texts: Is there any table in the database that shows the relationship between vocabulary and taxonomy, or is there any way to find out the vocabulary name of a particular taxonomy from its tid?


texts:
Is there any way to create a basic page within a basic page?
For example, when you create new content, you have the option of making a top menu.
Within that basic page you have just created, can you also make another basic page with a top menu within that basic page?

Sorry if this is confusing.


texts: Is there any gain using Memcached module when APC is running good on large Drupal 7 site (one server)

texts:
I am successfully using the APC Cache module on my prod website (single server). APC is performing good, caching is done very well. I wonder could I gain anything more by implementing Memcache.

I tried it briefly on dev server, I see they can run one with another (Memcached Admin shows many hits in log). But i do not see any performance gain (haven't done precise measurements).

I should mention it is pretty large site, i use 256MB for APC (sometimes cache use is almost full), there is many content types, fields, nodes(over 10k), contrib modules (425 tables in db).

I am pasting at the end of the question my settings.php config (dev, prod just have not memcached implemented). There seems not much logic if i use cache_default_class twice, as Memcache will be used (declared lately).

So - have anyone used those two together when using one server? Is there any performance gain ? What are config ?

In addition, Memcached Readme.txt suggests using

$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

but APC Readme.txt does not suggest that. I wonder why ?

Here is my code (using APC for Drupal backend cache)

# APC
$conf['cache_backends'] = array('sites/all/modules/contrib/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

# Memcache
$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';


texts: Correct way to append value to serialized array in key_value table

texts:
I have a serialized array in the value field of key_value, to which I constantly what to append values. An easy way to do this is to get the array, append the new value, and reinsert it. However, with a large enough array it's quite inefficient and in theory it can be done on an SQL level.

What's the correct way to do this in Drupal 8? Is there a way that does not involve getting and then setting the array?


texts: Code to display multiple images using .tpl.php file in drupal 7

texts:
I use the following code to render the image from the template file. This code is used when the image name is known. Multiple images can be displayed by adding the same lines of code with different image names.

global $base_path;
print "<img src='" . $base_path . path_to_theme() . "/../../../default/files/styles/thumbnail/public/xyz.jpg' width='100' height='100' />";

Is it possible to render the multiple images from the content type with the field name created but without changing anything in the template file every time we upload the image?


texts:
according to newrelic's dashboard /page_manager_node_view is:

most time consuming (97.1%)
slowest average response time (2050ms)
apdex most dissatisfying (95.6%)
highest throughput (14.4rpm)

I have apc and memcache enabled, yet to crawl about 8k pages and that's after some optimization (enabling cache on some of views) I was able to get down to 237min instead of 460min (before enabling cache on views).

we're using pressflow-6.28 on redhat6.4 w/ php5.3.3, there are two web heads residing behind varnish-3.0.4, web heads doesn't seem like experiencing heavy loads (0.2 15 min).

.. this is too much .. any suggestions?


texts: Get Plugin Definition methods using dependency injection

texts:
It is my first time defining a custom Plugin Type.
I think that this might be a comming thing in Drupal but I was not able to find any documentation anywhere.

I want to get Plugin definition methods from controller.

I use this code to get plugin definitions:

$type = \Drupal::service('plugin.manager.task');
$plugin_definitions = $type->getDefinitions();

And that gives me an array of all definitions with Plugin id, class and name.

What I want is to get methods from the definition class.

I don't know if I should create a service for every Plugin definition, but that doesn't seem to be a good idea.

Does Drupal Core have any tools to do this?

Hope that you understand.


texts: Conditionally run a view if another view has no results

texts:
I have a client who has an Upcoming Events view. However, when there are no upcoming events, he wants to show another view (Past Three Events) which shows the past 3 events. Basically he doesn't like it when the page doesn't show any events so he wants to show something.

I thought of attaching another block of the Past Three Events to the bottom of the main view (Upcoming Events) and then using jQuery to hide it if the main view (Upcoming Events) is populated.

But I was hoping that someone knows a more elegant solution where perhaps either I can conditionally run a view (perhaps using EFQ which I know nothing about) or somehow adjust views to combine 2 queries in one.


texts: Rule check if field value changed give always true

texts:
I need a rule that checks if the value of a field has been changed by a particular role.

I created a rule with event "After updating existing content".

I added two conditions :

user has role :

Parameter: User: [site:current-user], Roles: Web Team

NOT data comparison :

Parameter: Data to compare: [node:body], Data value: [node-unchanged:body]

What I expect is to see the rule fired when a user with role "Web Team" changed the value of the body field of a node.

I expect the rule NOT to be fired when a user with role "Web Team" edit and save a node without changing anything.

And I expect the rule NOT to be fired when a user with no "Web Team" role edit and save a node.

But everytime the user with role "Web Team" edit and save a node, regardless if he changes something or not, the rule is fired.

I tried to change the event in "Before saving content" with no more success.

The log displayed after the save is the following :

0 ms Reacting on event Before saving content.
12.599 ms Evaluating conditions of rule test2. [edit]
19.604 ms The condition user_has_role evaluated to TRUE [edit]
23.194 ms The condition data_is evaluated to FALSE [edit]
23.23 ms AND evaluated to TRUE.

How AND can be evaluated to TRUE if one of its conditions is evaluated to FALSE?

I did many tests but really don't see how to solve that.

I hove somebody could help me.

Here is the rule exported :

{ "rules_test2" : {
    "LABEL" : "test2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "workflow_rules" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "5" : "5" } }
        }
      },
      { "NOT data_is" : { "data" : [ "node:body" ], "value" : [ "node-unchanged:body" ] } }
    ],
    "DO" : [
      { "workflow_rules_set_state" : {
          "node" : [ "node" ],
          "workflow_state" : { "value" : { "11" : "11" } },
          "workflow_comment" : "Title or body modified by webteam. The content should return to contributors for validation."
        }
      },
      { "drupal_message" : { "message" : "node-title = [node:title]\r\n\r\nnode-body = [node:body]\r\n\r\nnode-unchanged-title = [node-unchanged:title]\r\n\r\nnode-unchanged-body = [node-unchanged:body]\r\n" } }
    ]
  }
}

Best regards


texts: Ways to specify different versions of nodes?

texts:
I'm creating a dev portal for a client's software, and they would like to have nodes pertaining to different versions of the software in the documentation.

Rather than have to make an entire new set of nodes for each version of the software, I would like to be able to add/edit a 'version' of the node that pertains to 1.x 2.x etc, within the node edit screen, and control what version the end user sees with a custom module and/or $_GET variable.

My first thought is to use the translation module since this is essentially the same thing, albeit with languages instead of software versions, but I was wondering if anyone had any ideas of what method I should go about doing this?


texts: Views Filter with Checkbox and Searchfield

texts:
I am searching for a solution to generate a custom filter consiting out of two fields. I want to have one Dropdown which holds the fields of my view, and then a second field "textfield" which will hold the search variable.
Here's an example. I do have a view with ID, name, email. My two filters would be a dropdown containing ID, name and email. And when I type something into the textfield, the field selected in the dropdown will be the filtered one. Does anyone know a module that does that? If not, I will write one.
I've checked Global combined filters so far, but they don't do what I want.

EDIT: just in case my question wasn't clear enough, this is what I want to achieve. And still got no idea how to.


texts:
What I want: In hook_media_presave I want to set a field value according to the same field on the referring node.

By the referring node, I mean the node where the media entity is created through an entity reference field.

I don't know if this is possible at all, but if it is, then how?

My current approach is to get the node from the route like this inside the presave hook:

$node = \Drupal::routeMatch()->getParameter('node');

My problem: The node I get from the routeMatch doesn't contain the new changes. Is there a way to somehow get them using the routeMatch, or is there another way to get the node.

I thought maybe the media entity had some kind of getReferringEntity() method, but no.

Is this the correct approach, or am I wrong?


texts: Adding variables in db_query for webform dynamic select

texts:
I would like to populate a dynamic select option in page 2 of my webform based on the value of another select option in the previous page.
I would like to use a variable in db_query, and hence tried this. But it doesn't work. I am not sure where I went wrong. Kindly let me know how I could solve this problem.

$array = array();
$major = $form_values['submitted_tree']['choose_your_major'];
$sql = db_query("SELECT data FROM webform_submitted_data WHERE nid = 2133 and cid =23 and data = '%s'", $major);
while($row = db_fetch_object($sql)) {
    $array[] = $row->data;
}
return $array;


texts: Can I use bash only instead of Drush to config revert and cache rebuild?

texts: Installing Drush on production servers can be difficult. I'm using rsync to move my file to the server. I only need to revert the config and rebuild the cache. Can I do that with pure bash and no extra dependency?


texts: Get $form_state backup and migrate filter extended class

texts: I have form altered the backup and migrate quick backup screen (admin/config/system/backup_migrate) and added a text field. I'd like to use the value of the field to create a new node just before the backup is done. I found a way to "hook" backup and migrate just before it performs a backup, which is great. However, I need to get $form_state['values']['my_value'] and pass that to my function that creates a new node. I can't figure out how to get that passed to the pre_backup() inside the extended class backup_migrate_filter.


texts: How to add Login menu to the first sidebar (secondary menu)

texts:
I need to remove from the 'secondary menu' the login/logout menu from the header, and display in the first sidebar,

It doesnt seem to be as easy as just draging and dropping in blocks,


texts: programmatically create one bean block to the default theme

texts:
I am trying to programmatically create beans in a custom module using entity_metadata_wrapper. This is creating a bean for each installed theme. (In Drupal 7)

Is there a way I can create only one instance of the bean block?

for example in my database it creates a bean block for

my subtheme
omega
seven

I would like to only create one block/bean for my subtheme. I am then using mymodule_beans_block_info_alter(&$blocks, $theme, $code_blocks) {} to then change region location and other block parameters.

function bean_ctas_enable(){
    foreach(bean_ctas_info() as $bean_content){
        $bean_ids = array();
        $bean = bean_create(array('type' => 'block_cta'));
        $bean_wrap = entity_metadata_wrapper('bean', $bean);
        $bean_wrap->label->set($bean_content['label']);
        $bean_wrap->title->set($bean_content['title']);
        $bean_wrap->field_text->set(array(
            'value' => ($bean_content['field_text']),
            'format' => ('full_html'),
            ));
        $bean_wrap->field_link->set(array(
            'url' => ($bean_content['link_url']),
            'title' => 'Read More',
        ));
        $bean_wrap->save();
        $bean_ids[] = $bean_wrap->bid->value();
        //set variable to store bean ids
        variable_set('bean_ctas_bean_ids', $bean_ids);
    }
}


texts: .htacces configuration for hosting an application in a subfolder with shared hosting

texts:
I am hosting my application using one of the hosting providers with cpanel. Its a Drupal 8 application in a subfolder named example and to do that I had to edit the .htaccess file like below.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.co.zw$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.co.zw$
RewriteRule ^(/)?$ example/index.php [L]

I got the above .htacess config from this article.
The problem is its only working well if the user types in https://example.co.zw/ but if the user types example.co.zw (without the protocol) it then resolves as https://example.co.zw/example/index.php
What directive can I add to the .htaccess file for it to resolve properly even if the user ommits the protocol.


texts: How to use form_set_value for a select list field?

texts:
Drupal 7. in my validate form function, I use form_set_value to set the value for the field "statut_metier" to 'draft'

If my field is a text field, this code works :

form_set_value($form['field_statut_metier'][LANGUAGE_NONE][0]['value'], 'draft', $form_state);

If my field is a list(text) field, with the key for the value 'draft' = 5

I can't manage to have the form_set_value function work.

Using Devel and dpm() I have search to reach this field value :

I have tried :

form_set_value($form['field_statut_metier2'][LANGUAGE_NONE]['#value'][0], '5' , $form_state);

but it doesn't work.

Any idea ?


texts: Display Suite: Edit tab missing on user profile

texts:
Using Display Suite (DS), I've overridden the user profile page in order to create a custom layout. However, the edit tabs that would normally appear when a user is logged in are no longer visible. How can I add them back?

I'm not sure if it's a factor, but I'm also using a custom-made Panels template within DS. Since I'm only using this layout on the user profile, I'm open to adding the edit tabs directly to the template, if possible.

I'm open to any methods that would be considered "best practice". Thanks in advance!


texts: What do I need to pass to the Image class as the first parameter?

texts:
I'd like to use the Image API directly to perform few simple operations with images (I'm aware of image styles and for various reasons I would prefer to not use image styles for the application I'm working on). The trouble I'm having is what I need to pass to the Image class as the first parameter. The constructor of the Image class expects an ImageToolkitInterface $toolkit as the first parameter. I'm not sure what to plug in for it.

Hunting around the forums, I see people have used \Drupal::service('image.toolkit') to pass in as the first parameter however this isn't working for me.

Here is a snippet of one of the operations I'm attempting to perform. Feel free to pan my whole approach.

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Image\Image;

class myImageController extends ControllerBase {

  public function imageHeight() {

    $image_path = 'public://path/to/image.jpg';

    $image = new Image(\Drupal::service('image.toolkit'), $image_path);

    $image_height = $image->getHeight();

    ksm([$image_height]);

    return [

      '#markup' => $this->t('Did this work?'),
    ];
  }
}

Does anyone know what I should use to pass in as the first parameter? I'm only using the default GD2 Image toolkit. Also, I'm on Drupal 8.6. Thanks!


texts: Taxonomy term title as page title in custom view

texts: I have a custom view where I show a list of nodes by taxonomy term. Since there are many terms in dictionary, I can't describe every view page manually. Is there any way to set the page title as a taxonomy term title?


texts: Mutliple forms, form submissions and calculations

texts:
I have the following scenario and I wonder how to make the best custom module or if there are some contributed modules I could use for this.
Scenario:

I have a site with 100+ different forms and a contact info form in each form.An anonymous user submits one form. This form needs to be sent to the correct users of Role A and have the same tag in their profile as the form. So, not all users with Role A get to see the submitted form.
All these users then can fill in a comment field and number field. All users can see the lowest number.
After X time an email will be sent to the anonymous user (contact info form) with the number and comment of the user with the lowest number.

Questions:

What is the best way to build this in Drupal? I was thinking with entity forms but how to tag form (like a taxonomy) and get it only sent/viewed to users with that tag? Also, each form needs to have the contact info form.

How can users send comment and number for this submitted form (only lowest 5 numbers need to be saved in database + comment field).

After X time send email to email address (from contact info form) with the lowest number and comment.


texts:
Does any one have an example how I can query the paragraph entity type of a given node ?

Let's say I have a node that contains a field 'field_paragraph' that is linked to the paragraph module . How do I query all that data ?

Thanks,
Yaron


texts: Rules - Use data from webform field in new entity type

texts:
I currently have a webform with the following fields:

Your Email
Your Name
Your Idea

Alongside this I have setup a rule that when a webform is submitted it creates a new node of a new content type I have created 'Idea'. A view then pulls in all these 'Ideas' to display.

The title of the node pulls in the Your Idea field using the value [data:your_idea-value] which works fine.

But I am trying to set the author of the node as the Your Name field but I am struggling, it doesn't allow a value to be used and can't figure it out.

I've managed to get it working where it sets it to Anonymous and then I setup another action on the rule to rename the author:name but it does it for all of the content, not just the new node.

I'm sure I'm just missing something simple, would be great if someone could assist.

Currently setup to set author as anonymous for the time being.


texts: Some MyISAM tables not converted to InnoDB during 6 to 7 upgrade

texts:
When I upgraded from Drupal 6 to Drupal 7 using the upgrade script I was under the impression MyISAM tables would be converted to InnoDB. This doesn't seem to be the case. Tables like comment, node, and block and many others remain as MyISAM. Tables like cache and field_* are InnoDB.

As far as I can tell it's best practice to use InnoDB. My website is a blog and forum, so users are posting comments, creating nodes, and voting on content. The site serves up an average of 30k pageviews a day.

Assuming everything was InnoDB I configured MySQL with: innodb_log_file_size = 256M and innodb_buffer_pool_size = 11G.

I believe it makes sense to convert all my tables to InnoDB. I wanted to ask here to see if anyone ran into this issue (conversion not taking place) or if anyone knew why the tables weren't converted. And, if I do convert everything to InnoDB, is there anything I need to know?


texts: alias the path of single - node views (pagination on single nodes)

texts:
I would like to effectively replace the nodes with views that would show the "full content" of a node with items to display set to 1. (Each paged page of the view would thus include only one node and the pager - effectivly i'm trying to use views' pager for nodes).
Now, what I am missing is the possibility of having aliases of the paths that include given nodes. I would like the pages to have paths like site.com/myview/nodetitle, not site.com/myview/1.
The aim is to replace the links to nodes in a context of a given view by links to single - node views, thus obtaining views pagination on node-alike. So the "title" field would be linked to, say, site.com/myview/nodetitle, wichh would be the single - node - position in a that has the same cireteria etc as the one I am coming from, but with full node view and a views pager. I am trying to replicte the features from views-navigation.
Is there any way to achieve that?
EDIT: i do not want to use contextual filters, as I do want the view to include many nodes, with 1 node showing per page


texts: How to find where are defined tokens for Redirect?

texts:
After enabling Token and Redirect modules, I've found at /admin/help/token that I can use Redirect tokens. For example:

However, I've got the problem finding the place where and how these tokens are defined (which file and hook or class).

Any ideas?

I've tried to search inside all files in docroot, e.g.

$ grep -r "The URL of the redirect" .
(nothing)
$ grep -r "The URL of the" .
(returns everything apart of redirect, no matching placeholders found)
$ grep -r token modules/contrib/redirect/
modules/contrib/redirect/config/install/views.view.redirect.yml:          tokenize: false
modules/contrib/redirect/modules/redirect_404/config/install/views.view.redirect_404.yml:          tokenize: false
modules/contrib/redirect/modules/redirect_404/redirect_404.routing.yml:    _csrf_token: 'TRUE'
modules/contrib/redirect/src/EventSubscriber/RouteNormalizerRequestSubscriber.php:      // Strip off query parameters added by the route such as a CSRF token.
$ grep -r redirect modules/contrib/token/
modules/contrib/token/src/Controller/TokenCacheController.php:   * Clear caches and redirect back to the frontpage.
modules/contrib/token/src/Controller/TokenCacheController.php:    return $this->redirect('<front>');
$ find modules/contrib/redirect modules/contrib/token -name "*.tokens.inc"
modules/contrib/token/tests/modules/token_module_test/token_module_test.tokens.inc
modules/contrib/token/token.tokens.inc (Note: nothing here for redirect)

So basically I couldn't find the source which module is defining those. This can help me in order to find out, why some of them aren't working as expected.

The main reason I ask this, because I would expect for redirect URL such as /foo/XXX, to return XXX when using [redirect:url:args:last], but these tokens aren't populated at all.


texts: Fresh installation on the same server where another core version was installed gives error

texts:
I have my own remote server to play around. I gave Drupal 8 a go but decided today to delete it from my server and install Drupal 7.56 again.

So I deleted all files via FTP and deleted all tables in phpMyAdmin, uploaded the Drupal 7.56 files from a fresh package I downloaded from drupal.org but ran into this issue:

When running through the process of install.php I suddenly get these 2 error:

Notice: Undefined variable: app_root in include_once() (line 690 of /var/www/clients/client1/web3/web/sites/default/settings.php).
Notice: Undefined variable: site_path in include_once() (line 690 of /var/www/clients/client1/web3/web/sites/default/settings.php).

So, after some Googling I found out it might have to do with the setting.php file of Drupal 8. The thing I don't understand is how this fresh install can search for the settings.php file of the Drupal 8 installation whilst I deleted every single file and table?

I checked my settings.php file of the Drupal 7 installation and there are only 648 lines, so I have no idea where to go searching...


texts:
I have a weird issue with a D6 site... A block I've created will not show up on the page. It appears to be disabled in the blocks list, although other blocks that /are/ showing up seem to be disabled as well. When I try to move it to a region, it jumps back to 'disabled' region.

Has anyone run into this issue and found a solution? Any help would be much appreciated!


texts: Is there a way to include jQuery-1.10.2 for specific php functions?

texts:
I need to include jquery-1.10.2 for a module I am building in Drupal 7.  The problem is, if I include the file with drupal_add_js in the module's .inc file, it causes the admin menu to display strange (there is no space reserved for it on the screen, so it is usually covered)  I've gotten around this by calling drupal_add_js right inside the page callback function for the pages that need jquery.  When I do this, the admin menu works fine, but if you click on any items shown in the overlay, the first time you click, there is a javascript error saying:

  Uncaught TypeError: Cannot read property 'msie' of undefined

If you click the same button a second time, the overlay will load, but I need to fix this so that there aren't any bugs.  I've done some research and it looks like this is because $.browser is depreciated as of 1.9.

So I was wondering if there is a way to include jS but to only have it applied to a specific function or maybe only to the 'content' div of the page?  I did find hook_init which supposedly runs whatever commands are inside the function as the pages for that specific module are loaded, however it still seems to apply the include to all pages of my Drupal install.


texts: In subtheming Commerce Kickstart, how to load my own background image?

texts:
I followed the instructions in this drupal.org article to subtheme Commerce Kickstart theme, but one thing I didn't get. I have changed the background logo bg.png to my own. Create directory my_theme/images, and put the new bg.png there. There is a line in MyTheme_style.css,
in section 1. Global:

body {
  background: #ececec url("../images/bg.png") left top; }

I've supposed then that the bg.png charged woul'd be my own, but it doesn't happen.

By the way, I first subthemed Commerce Kickstart theme with drush, and followed the other steps to make changes in MyTheme.info file.

I tried provide full path in url("../images.bg.png"), but still not working.

Am I missing something?

Edit: I will explain in details.

First I made a sub-theme of commerce kickstart with drush.

$ drush dl omega_tools
$ drush en omega_tools
$ drush omega-subtheme "The New Theme Name Here" --base=commerce_kickstart_theme --enable

To change some css attributes I create the file livraria-acervo-theme-alpha-default.css, where livraria-acervo-theme is my theme name. That file overrides the attributes changed from commerce-kickstart-alpha-default.css. Ok, works well.

But I need to change some global attributes that are in global.css. Then, from the drupal.org article cited, I follow some parts, as other was already done by drush. File livraria_acervo_theme.info was created by drush. But the code block

; OPTIONAL STYLESHEETS

css[livraria_acervo_style.css][name] = Livraria Acervo theme global style.
css[livraria_acervo_style.css][description] = This file holds all the globally active custom CSS of Livraria Acervo theme.
css[livraria_acervo_style.css][options][weight] = 12
settings[alpha_css][livraria_acervo_style.css] = 'livraria_acervo_style.css'

except the last line, was added in livraria_acervo_theme.info file

I think including this code block in livraria_acervo_theme.info file and create livraria_acervo_style.css and put it in path livrariaacervo/sites/all/themes/livraria_acervo_theme/ would cause my changed attributes in livraria_acrevo_style.css to take effect. But it doesn't.

I also created livrariaacervo/sites/all/themes/livraria_acervo_theme/images/ directory and put my background image bg.png there, and in

body {
  background: #ececec url("../images/bg.png") left top; }

I change "../images/bg.png" by "livrariaacervo/sites/all/themes/livraria_acervo_theme/images/bg.png", but didn't take effect.

The fact is that the livraria_acervo_style.css isn't used, as inspecting the chanted attribute in DOM, the file that is used is commerce_kickstart_style.css

It's my first time with sub-theme a Drupal theme, so I think is something I'm missing.


texts: Where to write public, common, utility functions in Drupal?

texts:
At times you have to write little utility functions which will have a general scope (not restricted to the module you are working on) so that it can be called from anywhere in the project.

I know I can write it anywhere and include the php file from the caller, but is there a convention followed in Drupal?

For e.g. I am working on xyz.module which does xyz thing which will have a silly

function startsWith($haystack, $needle) // case-insensitive startsWith
{
    return strncasecmp($haystack, $needle, strlen($needle)) === 0;
}

Where shall I write that function?


texts:
I need to change the text color of a block on my main page.  The existing theme uses blue text on a light blue background which makes it somewhat difficult to read.  I used Firebug to find the div ID and created a local.css file per this post.

#block-views-team-events-calendar-block-2 .content
{
color: #ffffff;
}

I changed the color to white, but, I don't see any change on the page.  I tried clearing the cache, but, I got the same results.  How can I change the text color for one single block on my main page?


texts: How save and get cookies after wrbform form submit

texts:
In Drupal 8, Create a form using webform.
Display form by using block on every page.
I want to save cookies after webform form submit.
By using hook_form_alter(), and user_cookie_save(['xyz' => 'abc']).
But cookies not save.
and showing warning in log file

Warning: Cannot modify header information - headers already sent by (output started at /drupal/core/modules/big_pipe/src/Render/BigPipe.php:264).

My question is how save and get cookies  after wrbform form submit.


texts:
Similar to Aegir no longer seems to be adding SSL info to apache config files for sites

The documentation still mentions a way to use commercial certs: https://docs.aegirproject.org/usage/advanced/ssl/#commercial-certificates

I too have run into the problem aegir_https not working the same way regarding chain certs.

Running aegir3-provision/stable,stable,now 3.182

LE is not an option for our org unfortunately.

Is there a way to use commercial apache certs with aegir_https/hosting_https?


texts: How can I embed the content of a field into the content of another field?

texts:
If I have a news site where I can select a source e.g. a press agency (given by a Taxonomy field) when creating a new article, how can I put this source at the beginning of the article text when viewing it? Like this:

(SOURCE) Beginning of article blabla............................

I already found a solution by using three different custom templates for getting rid of all the html wrappers and then floating the article text around (SOURCE), but there must a better solution like manipulating the node array or sth?


texts: Why Drupal 7 takes too time in connecting to mysql db? - measured with xdebugger

texts:
i have drupal 7 on localhost (core i7 - 12gb ram etc)
on Nginx with APC and mySql on windows7.

standard installation with standard theme and a bounch of new modules. about NO content.

The problem is that the homepage take ever 1,5 sec to load (without APC 3 secs).
i installed XDEBUGGER and with winCacheGrind i discovered that 75% of the time is lost in DB connections. Self: 2ms, Cumulative:1007ms

i tried almost anything i found on google... also i ported db engine to MyISAM... mySql is configured with my-HUGE.ini file... so it can take any resource from the computer.

How could i solve this?

1,5sec for any loggedin user is too much time... on the hosting this time will be greater as i won't have a so big dedicated server...


texts: How do I update Drupal Distribution (Commerce Kickstart) on shared hosting environments?

texts:
We currently run a Drupal Commerce site from GoDaddy C-Panel shared hosting environment.

I created the site with Commerce Kickstart and am now several distribution updates behind.

If that's the case, do I need to do the updates sequentially? (e.g. run three updates to get to the current version.)
Has anyone been successful with using Drush on GoDaddy to make these updates?

I read through the How-To documentation from Commerce Guys and wanted to run the updates with Drush based on the video posted there.

I followed the instructions on GoDaddy here: How to install Drush on cPanel Shared Hosting Everything seemed to go well, but nothing happens when I try to run the drush commands. Any recommendations on how to troubleshoot this?

So I think I will need to do the security updates all manually for now.


texts:
I'm using the flot module to create some graphs in Drupal. Generally, it is working pretty well. However, I have come across an issue which is more general.

I am defining a settings array, which works for most things, but some flot settings allow for anonymous functions:

  xaxis: {
    transform: function (v) { return Math.log(v); },
    inverseTransform: function (v) { return Math.exp(v); }
  }

How could I encode this in PHP so that it will be output correctly? The flot module uses drupal_to_js(), and I can't put it outside of quotes as PHP will try to interpret it. If I put it inside quotes it will be treated as a string.

From my googleing it looks like json_encode() also doesn't support this.

A little more explanation: drupal_to_js() takes a PHP structure and transposes it to JavaScript.

  $top = array(
    'a_string' => 'A string will convert fine',
    'a_number' => 123 // as will a number,
    'an_array' => array('a' => 'nested arrays work fine too'),
  );

This will be transposed to something like

 [ a_string: 'A string will convert fine', a_number: 123 ...

I want to transpose a function; the following code will give me the string 'function (v) { return Math.log(v); }'.

  $top = array(
    'a_string' => 'function (v) { return Math.log(v); }',
  );

The following code will give me a PHP parse error (as it should be).

  $top = array(
    'a_string' => function (v) { return Math.log(v); },
  );

I want the text in the string to be used as a JavaScript literal, but I don't think it can be done.

Has anyone found a good way round this? I could output some raw JavaScript, but then I will lose a lot of functionality.


texts:
I've installed - drupal commerce +  paypal + payment + commerce payment- modules.
Commerce seems to be working fine with regards adding and displaying products.
But in 'configuration', there is no list item there that says 'payment methods'.
I've enabled all related modules, so 'paypal wpp' and '..wps' etc.
Also installed and enabled 'payment' and payment commerce'.
What am I missing?

Any help would be great,thanks
Jon


texts:
I have been using Migrate API as a means to pull in RSS Data as nodes. Currently in Drupal 8 it doesn't seem there is any other reasonable way to do this.

One of my fields is a link that ends in a series of 6 numbers. I need those numbers as an id to go into the url. The substr plugin seems like it would be perfectly suited to accomplish this, but doesn't seem to work at all.

What I have in my YAML file :

grantid:
-
  plugin: substr
  source: guid
    start: 61
    length: 6

The error in my drush window when I attempt to even install the module that uses the plugin.

Unable to parse at line 61 (near "  start: 5").' in /var/beetbox/core/lib/Drupal/Core/Config/FileStorage.php:117

Currently I'm looking into using explode, but this is certainly not an ideal solution. Does anyone have some insight on why this plugin wouldn't work? It works fine without using this plugin.

Update : It does seem that was the problem. Thanks for the help.


texts: drupal 7 webform add classes to submit button

texts:
I am trying to add classes to my webform. In

hook_webform_element

I can do this

if ($element['#type'] == 'checkboxes') {
  $wrapper_classes = array(
    'form-item',
    'webform-component',
    'large-16 medium-8 small-24 columns',
    'webform-component-' . $type,
  );
}
else {
     $wrapper_classes = array(
    'form-item',
    'webform-component',
    'large-8 medium-8 small-24 columns',
    'webform-component-' . $type,
  );
}

But I do not seem to have access to the submit button. I need to add a couple of classes and also only do it on a certain form so suppose I need the $form_id.


texts: Devel's dpm needs two refreshes to display message from (pre)process

texts:
I use Zen and have copy/pasted the STARTERKIT to my foo template.
Devel is enabled with the "Rebuild the theme registry on every page load" setting on.

In my completely empty template.php I type in the following and save:

function foo_process_node(&$variables, $hook) {
    dpm('test');
}

I then do drush cc all and refresh page. The message is not shown. If I refresh again the message shows.

If I change test to foobar on the 1st refresh I get the old test and on the second I get foobar.

Why does this happen and how can I avoid it?

Note that this lagging behavior is the same for preprocess and process but not there if I print the message from the foo_page_alter(&$page) function.


texts: User activity not showing in the personal log but is in the public log using Heartbeat module

texts:
I have installed the Heartbeat module (6.x-4.11) with Heartbeat activity and Heartbeat rules enabled. If a user adds a comment to the site the activity is being logged in the database and showing on the public heartbeat page. However, looking at the user's personal heartbeat it shows as "no activity yet."

The uid and uid_target values in the database table are both "0" which I am guessing is not right (surely these should be the user's id).

Is there a configuration setting that controls whether the activity appears against the user?

I'm attempting to use this module as a way of allowing users to see how active other users are on the site; so it is important that the activity appears against the personal heartbeat.


texts: Cannot Find CSS Class For A Custom Block

texts:
Hello due to much help from here in the past im starting to theme whatever part of my drupal site that i like. Its great. Ive ran into a a strange one though. I have created a custom block (block 130). You can see it on top of my site

BBC Live Olympics | Add Olympic Comment | Football Livescore | OLB Olympics
http://onlinebanter.com/latest

For some reason it doesnt have any div class Im trying to change the p bit.

Ive tried various things but still cant seem to find this blovk. Does anyine have any suggestions?

Thanks


texts: How can I stop the Devel module from generating blog/forum entries for Anonymous user?

texts:
I'm using Devel's generate content feature to generate Blog/Forum entries for a site I'm working on and funny enough, I get to have a blog post by an anonymous user or forum topic by an anonymous user.

How can I stop Devel from doing this? I've only given Authenticated Users/ Administrators the permission to create a blog post or forum topic but still it generate for anonymous user. How can correct this?


texts: Aegir tasks not running, after accidentally upgrading drush

texts:
I have a BOA installation where I accidentally run the command drush self-update. This overrided the aegir-comparible drush with a newer version. When I realized the issue, two days later, I replaced the new drush with old one (4.6-dev), found in the backups.
The issue I am facing is that the tasks in the Aegir queue have stopped running. They give the message that they should run in the next cron, in about a minute, but then nothing happens. It keeps telling me that the last cron was run two days ago.

I have tried sudoing as Aegir and running the following:

drush vdel hosting_queue_cron_running -y
in case a semaphore is left, but this gives the message hosting_queue_cron_running not found.

/var/aegir/drush/drush.php '@hostmaster' hosting-dispatch --debug
and it runs fine, which means that the drush kicks the cron, but for some reason it doesn't reach Aegir

I tried to run barracuda up-stable in order to recover .drush, but it didn't recover it. I also tried to clean cache and rebuild registry. The time of the server is correct. Could you suggest some way to further debug the issue?


texts: How to install Accelerated Mobile Pages (AMP) without composer

texts:
I do not wish to use composer.
I wish to try out Accelerated Mobile Pages (AMP) (in D8).
Is this possible and how do I do it?


texts: Loading nodes that are only available to the current user

texts:
How do I programmatically load nodes that are available to the current user?
I used node_load_multiple(), but it seems to directly load nodes from the database, bypassing permissions.


texts: How can I check if an image style for an image has been created already?

texts: Is there a function I can use to check if a particular image style for a given image has been created already?


texts:
I am hoping to add Slick Library within my DrupalGap but when I try to use it, I am unable to.

The library is added normally within index.html but when one my node page (which has the HTML in it) tries to use it, it doesn't work.

Any idea how to do this correctly.


texts:
I need a field that will allow content editors to enter a rating while editing a node, with the options 'yes', 'no', 'maybe' and 'unknown'. I then want to be able to display those ratings in a view, as images (tick, cross, fence, ?). I need to be able to have more than one on each node.

I can't do this with the rate module, because it doesn't do fields (there is a rate field issue, but it's not moving very fast). Fivestar only does five-star ratings, so that's out.

Optionally, I would also like to be able to give each result a numerical value, so that I can do calculations across fields (e.g. median).

Are there any options out there that can do this kind of rating?


texts: Hello I Am New to drupal and i want to create a submenu bar under Menu Navigation So Can ANYONE Suggest And Idea Or Something To Create A Submenu In Other Page Like Shown On Image


texts: How to set default values for daterange widget in baseFieldDefinitions

texts:
Everything is working in my code except the default values...

$rangedefaults['value'] = DrupalDateTime::createFromTimestamp(time());
$rangedefaults['end_value'] = DrupalDateTime::createFromTimestamp(time());

$fields['date'] = BaseFieldDefinition::create('daterange')
  ->setLabel(t('Date and time'))
  ->setDescription(t('When the activity takes place.'))
  ->setRequired(false)
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'daterange_default',
    'weight' => -4,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE)
  ->setDefaultValue($rangedefaults);

What is the proper way to set default values for this widget?


texts:
There is a content type in a view who's display is based on a theming template. In this example, the template is called views-view-fields--article-list.tpl.php . This Case Study/Articles list template works great and as expected on the local testing server. Seriously, everything is working fantastico! Changes made to this template act as expected locally.

However, when the file is uploaded to the production server, changes to the template do not seem to be responding at all. Even after the cache is cleared, the changes are not taking effect. In fact, I deleted the template all together to see if that would cause any disruption, and nothing. It still behaves the same way. Also, flushed the cache in the top left of the admin menu.

So, question is...
Is there some sort of database change that needs to happen when I update the template locally and then upload to the server? Or, is there just something missing in general that is not allowing Drupal to re-scan the template files on the production server?

The server resides on bluehost, if that would be relevant, but I believe the issue is something in my Drupal files.

Ayuda, por favor?

---- I thought the below was the problem, but in looking closer, there is a weird caching problem with this file!!! It is still doing this and changes made to it are not refreshing normally. It must have something to do witgh the view's settings.

Here was the source of my confusion. When clearing the cache, the server wasn't responding to the changes I made in the template file. I'm still not sure what the original problem was. :( However, I had removed the template file and placed all the code from that file into the last view's 'Rewrite the output of this field option, and had re-formatted it to the correct format. But, I was seeing everything double (and broken), and assumed it was the old template file adding in its own code, thus the odd double vision!

What I forgot was to go to each field in the view UI and exclude its Display. So, yes  Jimajamma, it was at the end a palm to forehead slapping! Thanks for the troubleshooting ideas.


texts:
I am using Layout Builder to add blocks into my nodes. I am adding several instances of different custom block types to specific content individually.

I wander if it is it possible to export those blocks added to node through layout builder as a default content using: Default content module?

I have tried standard drush dce and while it exports the node, I could not find block data into exported JSON.

I tried drush dcer to export references as well but no luck with it as well.

I am thinking finding specific block IDs and export those entities manually one by one but before I do that I want to find out if there is a way to do it in more elegant fashion.

Also if this something new, it would be good feature to contribute to Default content module, so if we find out that's the case I would happily try to contribute.


texts: Problem with calling drupal_get_form from an AJAX callback

texts:
So, I have a paged, AJAX-enabled list view of entities. As a part of the entity build process for rendering, an AJAX comment form is built, rendered and attached to it.

Now, when I move to the second page in the view (retrieved via AJAX), the comment form shows up but the AJAX property is not attached to it anymore. I used Drupal 7's #ajax on the submit button. Also, the form action is now set to views/ajax when I want it to be the same as the original page. Any way to get around these two issues?


texts: I am working with an STI product for wowza media server to allow streaming video on our website made in drupal 7. I am using panels for the profile pages which will have 8 guest camera docks which is simple enough. it will also have a text chat as well as a main video dock for the person who owns that profile. Anyone know how I might be able to set a flashvar to the userid of the profile by variable so i do not have to custom code each profile as people sign up? I want it so when a user signs up they have a profile with all the features and those features are specific to that user so that when one person goes to broadcast it doesnt broadcast to every profile.


texts: How to implement expiring roles in Drupal 7 today?

texts:
I am in the processing of making a membership site that requires some user roles to expire after a set period of time.

The most obvious choice would be the role expire module but none of the 7.x releases have been updated in six months and the issue queue has some patches that have been marked as needing review for weeks.

Commerce subscription is another module under development that hasn't seen any action in about six months.

The only module I could find with a stable release is Commerce subscription products, which rather than being an independent module is actually a feature consisting of rules, commerce, and some fields (as per the module page).

As a site builder with a release coming in the next month or two, since it seems like there is no clear clean solution at the moment, would it be crazy to simply not implement any of these solutions and do something basic in rules myself, handling expirations manually for the first few months?  (Roles will expire monthly, and I don't anticipate more than 100 or so roles needing to be removed each month.)  Then, if use of the site started taking off, I could look at implementing one of these solutions again.  Or is there some good way to do role expiration today that I missed?