texts: Building a Views Table to display Commerce order information

texts:
I don't know whether this is possible to achieve in Views, or needs coding.

I want to be able to display Drupal Commerce Orders in a table, one row per order (as in default list provided by Drupal Commerce). I want the first 3-4 columns to show order number, order total, name of purchaser and date. No problem so far, it all works fine.

Now the difficult bit. I then want to have a number of additional columns, one for each category of product (taxonomy), and where an order contains a sale for a line item in each category, I want just the sub-total for that category to appear in the right category column.

For example, an order might contain £10 for a shirt (category/term), and £5 for a scarf (category/term). In the row for that order, I want the £10 to show in the column under the shirt category, and £5 to show in the column under the scarf category.

In spite of much research I cannot figure how to do this, or if it is possible, without coding the table.

Any help would be appreciated.


texts:
I want to update the configuration (weight, pages, region) of some blocks within an update function. I know I could do this directly inside the database. Is there a better way of doing this? I scanned http://api.drupal.org, but I didn't find anything like block_load() and block_save().

Do you have any idea?


texts: Showing all results of custom content type in every page

texts:
Essentially we have a custom content type called "Slideshow" with "title", "content", and "image" as the three fields.  We want our admins to be able to add new elements to the slideshow by simply adding new content with the slideshow content type.

Everything we have tried has failed miserably. All research indicates that we need to create a custom node template named node--slideshow.tpl.php and lay it out how we want (IE place the slideshow divs around our render($content['field_slider_image']), etc... but how do we then insert that into our page template?

I apologize if this is a stupid question or if we're going about this in an odd way.  The template has already been coded, so we need to be able let our admins add slideshow elements easily and have them show up on the front-end without them editing a "slideshow" block.

I hope someone can help us figure this out.

Edit - Just stumbled upon "views" and that looks very promising because it allows us to set up a 'slideshow' view which automatically pulls in the content of our slideshow content type.  If we go that route, how do we format the output?

Edit 2 - This slideshow will be at the top of the homepage only. Any other page will have the page title in that spot.


texts: View published content to anonymous users front page only

texts:
I have the Content access module installed, but it's not good for sorting this. I just want to make it so deny access is not denied on frontpage.

In permissions I have de-selected view publish content for anonymous users, but how can I make it so they can view the front page?


texts: Img tag getting removed in views drupal 8

texts:
I am trying to rewrite the results of a field to include an img tag.
The first part of the tag then gets stripped, the second part stays:

<img src="http://example.com alt="Image" /> results in alt="Image" />.

What is causing it and what will be work around for it.


texts: How do I create a rule to run during every cron run?

texts: I'm creating rules for posting to twitter. However I need these rules to run every time cron runs. What is the best way to structure these rules so they send the appropriate post at the appropriate time?


texts: Drupal7 user reset password link not working

texts:
Hi i have created a custom hook in my own themeplate

function mytheme_theme() {
  $items = array();

  $items['user_pass'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'mytheme') . '/templates',
    'template' => 'user-reset',
    'preprocess functions' => array(
      'mytheme_preprocess_user_pass'
    ),
  );
  return $items;
}

function mytheme_preprocess_user_pass(&$vars) {
  $vars['intro_text'] = t('This is my super awesome reg form');
}

This is the code in user-reset.tpl.php

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

  <?php print drupal_render_children($form) ?>

after the user register. an activation link will send to the user email
example: http://www.mysite.com/user/reset/98/1366527945/qr6sEqrJwpWjQ11sxQPpitIHosg3_-Iv1s08yrKlnYk

Problem is:

When user trying to click the link, the page give me an error "The page isn't redirecting properly"

is there anything i missed on my own theme?

cherrs


texts: How to get the ckeditor.js script to work on a site that uses the Google pagespeed module and Drupal's ckeditor?

texts:
On a Drupal 6 site I installed Google pagespeed module. It's working fine but my ckeditor.js script is not working.

I searched Google and found there is known problem with pagespeed and ckeditor.

All sites are saying to add a disallow ckeditor.js in the pagespeed.conf file. Well I tried but the ckeditor just doesn't work! Here's one url

drupals website discussing this issueI have the ckeditor module enabled for Drupal 6. The status report says it's ckeditor 3.5.1

Any suggestions to get this to work?


texts: Disable caching on a custom plugin block

texts:
I read a lot of posts on how to disable caching on a custom block but none seemed to give the perfect solution.

$build['#cache'] = ['max-age' => 0] or public function getCacheMaxAge() { return 0; }: Do not seem to work, or at least for authenticated users
\Drupal::service('page_cache_kill_switch')->trigger(): Kill the complete page cache, not only the block ones
Lazy builders: Seems to work only for anonymous users

In my case, I have a block which renders a random node and it's clearly an issue while I'm not able to refresh this cache.

So how to set up such a block? (Drupal 8.4.3)

Posts giving not working solutions:

How to prevent a block from being cached?
How do I correctly setup caching for my custom block showing content depending on the current node?

Edit:

public function build() {
    [...]
    if ($prev_node) {
      $render_controller = \Drupal::entityTypeManager()
        ->getViewBuilder($prev_node->getEntityTypeId());
      $build = $render_controller->view($prev_node, 'pagination');
      $build['#node']->field_custom = 'something';
    }
    return $build;
}

public function getCacheMaxAge() {
    return 0;
}

Thank's to @Clive, it seems my issue is not linked to the block cache itself, but to the entity I render in this block. If so, I have no ideas how on to resolve this issue.

After many searches, D7 cache_clear_all('field:node:10', 'my_field') function seems to do what I want to do. What is its equivalent for D8 ?


texts: How can I find a list of fields output by a view block?

texts:
FINAL UPDATE

Success! Apparently there were field-level permissions set on several of the CCK fields I needed, in spite of the original developer telling me that content permissions were not enabled. Once I allowed anonymous viewing of the required fields, they displayed with no problem.

I've created a view with a block display. The view has a grouping field, and in the views ui preview, the output displays as grouped by that field:

When I display the block using my template, though, it's not printing out the grouping info (Advanced Learning Session or General Session). That field is not a standard one, like title - it's a CCK text field on my content type. How do I access that field in my template? I've tried the solutions shown here to get a list of available fields, but none of them work.

Edited after trying @schnippy's answer

When I mouse over the field, I see this:

So I tried adding

<?php print "session type: ".$fields['field_session_type_value']->content; ?>

to my template, but although the "session type:" string prints, there's no value coming through after it. I've also tried writing just the value to the error log, in case there was something weird about combining it with a text string, but still nothing.

Edit again...

Just to provide a bit more info, if it will help - I'm using the mobile jquery theme, which has a views-view-list.tpl.php file to display views where the output is HTML List. That template looks like this:

<?php
// $Id: views-view-list.tpl.php,v 1.3 2008/09/30 19:47:11 merlinofchaos Exp $
/**
 * @file views-view-list.tpl.php
 * Default simple view template to display a list of rows.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $options['type'] will either be ul or ol.
 * @ingroup views_templates
 */

?>

<?php print $title; ?>

  <<?php print $options['type']; ?> data-role="listview">

    <?php foreach ($rows as $id => $row): ?>

      <li class="<?php print $classes[$id]; ?>"><?php print $row; ?>

    <?php endforeach; ?>
  </<?php print $options['type']; ?>>

I have a number of views that are being displayed via blocks with this template, and for the most part it's fine because they all are grouped by a title field. But for one view, the records are grouped by a CCK field called field_session_type_value, and if the value of that field matches a specific value, I want to print that field instead of $title.

Another update

According to views-view.tpl.php, $rows is the variable that views sends out as the results of the view query. Now, if I have multiple fields, I would expect that doing a print_r on $rows would return a multi-dimensional array - each record or row would be an array containing a key/value pair for each field. Like so:

Array (
  [0] => array('title'=> 'Advanced Consumer and Shopper Insight - An Interactive Symposium',
               'session' => 'general-session'),
  [1] => array('title' => 'Creating a Powerful Brand One Dirty Job at a Time',
               'session' => 'advanced-learning')
)

(Yes, I realize my pseudocode array is not formatted correctly. But you get the idea.) But that's not what I'm getting. What it's sending back is a single-dimension array, containing just the titles:

Array (
  [0] => Advanced Consumer and Shopper Insight - An Interactive Symposium
  [1] => Creating a Powerful Brand One Dirty Job at a Time
)

What do I need to do to make sure it sends all the fields through in the $rows array?


texts: Is it possible to write test against the current database?

texts:
I'm building some modules onto an existing and somewhat active site. From my understanding, SimpleTest creates a new, temporary database and effectively reinstalls a copy of Drupal.

However, I'd like to take over some current items for the existing site such as taxonomy and content types and test against this data.

Do I have to manually do this all in setup()? Or is there a way to clone or import existing tables into the testing database that SimpleTest sets up?


texts:
I am trying to loop through a taxonomy term's tid, but somehow all the array elements are protected. It was very easy peasy in Drupal 7 with:

 $term_id_1 = $node->field_term['und'][0]['tid'];

I am not sure how I could access tid(here is the kint() screenshot):

and here I how I get this and my broken foreach():

public function setCollection($collection) {
$collection_array = [];
$collection_ids =  \Drupal\taxonomy\Entity\Term::load($collection);
kint($collection_ids);
foreach ($collection_ids as $collection_id) {
  $keys = $collection_id->values;
  foreach ($keys as $key){
    $collection_array[] = $key->tid;
  }
}

$this->collection = $collection_array;

}

Question 1-> Is taxonomy terms are node?

Question 2-> Is this line correct to get the fields?

  $collection_ids =  \Drupal\taxonomy\Entity\Term::load($collection);

Question 3-> Can anyone lead me to get access 'tid' from this protected 'values' array?

Warm regards.


texts: How to get contextual filter of a view from page.tpl.php?

texts:
this is my page view path /news/[years]/[month]

I want to get year and month from path, how can do it ?

Thank you.


texts: How to reverse engineer a section of a Drupal Page

texts:
Sorry if this is a beginner or inappropriate question, but I'm trying to work on modifying a complex Drupal site and I have no idea how to find out how it's built.

At the top of the home page there's a bunch of content (specifically an image that moves and zooms like a google map) but I can't find anything about how to edit or control this area.

Where should I look? Views, Blocks, or in the Theme files? I've tried looking through all of these as best as I know but I'm hitting dead ends.

Thanks!


texts: Commerce product programatically with price

texts:
How do I get the correct price in the site's default currency to work like the the add product form does?

This function gives a product with a price of $0.01 I want $1.00.

I am sure this has to do with calculated price?

function generate_products () {

    $product_type = 'product';

    $values = array (
        'price' => 1.00 ,
        'currency_code' => commerce_default_currency() ,
    );

    $extras = array(
        'status' => 1,
        'uid' => 1,
        'sku' => randomName ( 10 ),
        'title' => randomName ( 10 ),
    );

    commerce_installments_create_product ($product_type,$values,$extras);
}

function commerce_installments_create_product ( $product_type , $values , $extras ) {
    $form_state = array ();
    $form_state[ 'values' ] = $values;
    $form = array ();
    $form[ '#parents' ] = array ();

    // Generate a new product object
    $new_product = commerce_product_new ( $product_type );

    $new_product->status = $extras[ 'status' ];
    $new_product->uid = $extras[ 'uid' ];

    $new_product->sku = $extras[ 'sku' ];
    $new_product->title = $extras[ 'title' ];
    $new_product->created = $new_product->changed = time ();

    if ( ! empty( $values[ 'original_order' ] ) ) {
        // field_original_order[und][0][target_id]
        $order = array ( LANGUAGE_NONE => array ( 0 => array ( 'target_id' => $values[ 'original_order' ] ) ) );
        $form_state[ 'values' ][ 'field_original_order' ] = $order;
    }

    if ( ! empty( $values[ 'original_line_item' ] ) ) {
        // field_original_line_item[und][0][target_id]
        $line_item = array ( LANGUAGE_NONE => array ( 0 => array ( 'target_id' => $values[ 'original_line_item' ] ) ) );
        $form_state[ 'values' ][ 'field_original_line_item' ] = $line_item;
    }

    if ( ! empty( $values[ 'original_product' ] ) ) {
        $product = array ( LANGUAGE_NONE => array ( 0 => array ( 'target_id' => $values[ 'original_product' ] ) ) );
        $form_state[ 'values' ][ 'field_original_product' ] = $product;
    }

    //commerce_price[und][0][amount]
    $price = array ( LANGUAGE_NONE => array ( 0 => array (
        'amount' => $values[ 'price' ] ,
        'currency_code' => $values[ 'currency_code' ],
    ) ) );
    $form_state[ 'values' ][ 'commerce_price' ] = $price;

    // Notify field widgets to save their field data
    field_attach_submit ( 'commerce_product' , $new_product , $form , $form_state );

    commerce_product_save ( $new_product );
    return $new_product->product_id;
}

//function based on answer here How do I programmatically create an entity with its fields?


texts:
We have a view, custom_view, that was created to be displayed on a page that is of the basic page content type. The basic page content type is using the Default View mode and has a taxonomy term, custom_tag.

Initially we thought about adding the block to the theme block layout, but that does not provide what we need. The custom_view should only be visible on the basic page content type for the Default View and not others.

How do you add Views to a View Mode?

The view has a contextual filter so it takes in the current language and it takes in the value of the custom_tag since it is present on the basic page content type.


texts: Drupal 7 module hook_preprocess_page &$vars

texts:
In my module I have verified this function is being called, but when I try to edit page--golfguide--alias.tpl.php it doesn't have the variables available.

In module:

function dc_branding_preprocess_page(&$vars)
{
    $vars['branded_header'] = dc_branding_header_contents();
    $vars['branded_footer'] = dc_branding_footer_contents();
}

In template.php for theme:

function golfguide_preprocess_page(&$vars, $hook)
{
    global $user, $is_mobile;
    if (isset($vars['node']))
    {
      // If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
       $vars['theme_hook_suggestions'][] = 'page__'.$vars['node']->type;

      // If the node id is "33" the template suggestion will be "page--33.tpl.php".
       $vars['theme_hook_suggestions'][] = 'page__'.$vars['node']->nid;
    }
    //Create page suggestion for first part of url-alias
    $url_alias = drupal_get_path_alias($_GET['q']);
    $parts = explode('/', $url_alias);
    $parts[0] = str_replace('-', '', $parts[0]);
    $vars['theme_hook_suggestions'][] = 'page__'.$parts[0].'__alias';

    if($is_mobile)
    {
        $vars['theme_hook_suggestions'][] = 'page__'.$parts[0].'__mobile';
    }
}

In page--golfguide--alias.tpl.php

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

NOTHING outputs and the key branded_footer does not exist.


texts: Run a view's bulk operation immediately but in background. Is that possible?

texts:
Is it possible to run a view's bulk operation immediately after pressing the button but in the background (in other words, without forcing the user to wait until the progress bar completes to 100%)?

I understand that this can be achieved by enqueuing the operation. But the problem of this solution is that execution is postponed until cron is run.

Thanks.


texts:
I have uploaded my drupal commerce files. I get the message that my credential are wrong.  I am just not sure whaht info they want for the

In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.

  Failed to connect to your database server. The server reports the following message: SQLSTATE[28000] [1045] Access denied for user 'admin'@'localhost' (using password: YES).

  Is the database server running?
  Does the database exist, and have you entered the correct database name?
  Have you entered the correct username and password?
  Have you entered the correct database hostname?

I though I knew all of this information.  I am running on my web host using admin as username.  Any help would be greatly appreciated.


texts:
Are there any good Ubercart hooks or other API features so I can learn about whether my Ubercart orders have been paid at all?

Basically all I need is a function that would tell me if an order invoice has been paid-in-full or not.


texts: Injected javascript in google DFP module drupal 7

texts:
Currently I am setting up the Google DFP module and I have been trying to work out how the JavaScript is working. In the module there is a section for injecting JavaScript which is what Google DFP will give you to place in the head tag on the website. When I place the JavaScript in the form where it tells me to place it, when I load the page up it shows some of the JavaScript at the top in the body (using the DFP module).

So I experimented around with this and took the JavaScript out. I was expecting the adverts to stop displaying, however they kept displaying after taking out the JavaScript and deleting the cache and I am confused as to how it is displaying the correct adverts.

Sadly I can't give a link to the website because I am using eclipse to test things out.

The module I am using is: Doubleclick for Publishers (DFP)

What I would like to know is how is this working? The JavaScript isn't there so how does it know what adverts to get? The only thing the module knows is the network ID and the advert tags using the [dfp_tag:slot] token.


texts:
I found a discussion with some methods for d6 here http://drupal.org/node/344802
on how to change the node "Save" button text to sg else.

Any tips for d7? I would prefer to use form api.


texts: Ship to multiple addresses on single order

texts:
We have below requirement,

We can add multiple products to single order(which is normal).
Our client expect a functionality to ship to multiple address in single order. Which means we should have option to add multiple address in single order and based on client's need, different products should ship to different addresses.

Any one has any experience or idea about the implementation? Or we have to write our custom module for the functionality?


texts: Set default frontpage to Front Page view

texts:
I've setted the Default front page to the View Front Page, but when I go to www.mydomain.com the page don't redirects to www.mydomain.com/frontpage.

When I go and write www.mydomain.com/frontpage the Front Page view is displayed.

What is going wrong?


texts: Show first view result, but show next result when the view's cache is cleared

texts:
I'm trying to show a featured image on my homepage.
This image will be pulled in by a view that returns 1 result.
I then change the caching of the view to 1 day.

What I would like is for each time the cache resets the view to return the next row.

Day 1 - image 1
Day 2 - image 2
etc..

I can add the sort criteria: 'Global: Random'. But then you have the chance that some images might be shown on consecutive days and that some are hardly ever shown.


texts:
I am able to do the HTTP GET request using cURL in my custom function, my code below works fine for me, but is there Drupal way to do this?

function some_page_callback() {
    $url = 'https://api.example.com/data';
    $accesstoken = 'SoMedGFidHThX2NvdW50eV90bWNhOkEyakJEM2ND';
    $headr = array();
    $headr[] = 'Accept: application/json';
    $headr[] = 'Authorization: Basic '.$accesstoken;

    //cURL starts
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($crl, CURLOPT_HTTPGET,true);
    $reply = curl_exec($crl);

    //error handling for cURL
    if ($reply === false) {
       // throw new Exception('Curl error: ' . curl_error($crl));
       print_r('Curl error: ' . curl_error($crl));
    }
    curl_close($crl);
    //cURL ends

    //decoding the json data
    $decoded_data = json_decode($reply, true);

    // putting the data into table
      $rows = array();

      $output = '';
      // Example of theme_table().
      $output .= '
Example
';
      $headers = array(t('ID'), t('Name'));

      foreach ($decoded_data['data'] as $line) {
          $tablerow = array(
          array('data' => $line['id']),
          array('data' => $line['name']),
         );
          $rows[] = $tablerow;
      }
      $output .= theme('table', array('header' => $headers, 'rows' => $rows));

return $output;
}


texts: Where is the information in the node_info hook displayed in drupal

texts: I am beginning with drupal. I cannot see where the information which I write in the hook node_info displayed in drupal. What is the link to check it?


texts: I need to alter the structure of the OG Menu to build it into a Mega Menu. I'm using the OG Menu: Single block so that it's dynamically rendered. Is there a hook that will let me alter it? I can't find anything in the docs.


texts: I'm working on a Open Social (Drupal 8) implementation. When adding an event you can submit the begin & end date. Is there any way to change the date format in these forms? I went through the whole system, found a lot of date format settings, non of them had any influence on this form.


texts: How to easily create and reference a node / entity during creation of another one?

texts:
I have the task of attaching two entities to each other, and both may not exist yet. So what I'd like is to create the second entity along with the first one if it does not exist yet.

So in the case of having a task and attaching persons, assume I already have created a person. Then I would like to add him to the task by typing in his name.
But at the same time, when editing a task and the field does not find a name, I like to receive the option to create the person entity on demand.

Are there recommendations as of how to approach this?


texts: Adding conditions to the template file of a view

texts:
I'm setting up a webshop in drupal and I bought a template.

The tempate has a compare products function embedded, that works with a button on the product pages, however, I would only like that button to show up at certain types of products, like TVs and phones etc., but not for the rest.

The compare button, however, is hardcoded into the template file and not manageable from views, so I have to add the conditions to it there, in PHP - to only appear on the node pages of products that have a certain taxonomy term attached to them.

 <div class="actions">
    <?php print flag_create_link('wishlist', $node->nid); ?>
    <?php print flag_create_link('compare', $node->nid); ?>
  </div><!-- .actions -->
</div>

This is the section in the code of the node--product.tpl.php file that puts out the action buttons. I need the second one, the compare button to only appear for nodes that have a certain taxonomy term.

I don't really know php, except for very very basic syntax, so I would be really grateful, if someone could describe in detail how to implement a solution, perhaps even provide a snippet of code that I can customize and paste there!

Thank you in advance!

Huba


texts:
Are there any opportunities to create "classic" playlists with Audio or any other similar modules? I primarily would like to let mp3-files be played, but in a way that it cannot be easily directly downloaded (considering the fact that as it's written on Audio module's admin interface, "You should be aware that even when audio is not marked as downloadable, clever users can still download it, this just makes the work harder.")

After uploading some separate Audio nodes, Audio players can be displayed via Views module like this (with some randomly uploaded tracks):

But this is NOT a good solution for me as it's not like a normal playlist, as these are separate audio players...
There is support in Audio module for the little bit ugly-looking XSPF Web Music Player - Extended, but I didn't find any opportunities to create a playlist with it either.

Any suggestions with Audio or any other suitable modules?
Thanks!


texts: How do I add a placeholder into the password field?

texts: How do I add a placeholder into the password field using the Logintoboggan module?


texts: How can I affect a custom block to a custom page/view in Drupal 8?

texts:
I know I can choose the page were the block Will be displayed but for a big website I Will have hundred block on same région on same admin menu, it Will be hard to handle this. Is there a way to separate the custom block or create a new space for région, because if I place a custom block in a region, this custom block Will be automatically display on all page , ans I dont want that.

Thanks.

( for drupal 8 )


texts:
I have a view (Drupal 6 / Views 2, but I think this may apply to other versions as well) displayed as a sortable table. I can add fixed sort criteria as you can with all views, but once the table is sorted by the visitor on a certain table, those sort criteria are ignored.

In the style options there is a box called "Override normal sorting if click sorting is used", which doesn't make sense to me. It seems to effectively disable click sorting, leaving the end user with a clickable but not working table headers.

Is there a way to keep the fixed sort criteria and use them as secondary criteria?


texts: Custom content type displayed without theme

texts:
Working in Drupal 7, I've created a custom content type "Announcement", intended to be distinct from the regular Article type. I haven't added any custom fields or anything esoteric.
The thing works, I can create Announcements and they show up as teasers in a blocks view I have set up for the purpose.
But when I click the teaser link, the announcement page is displayed as a basic HTML page - no theme. I'm using the Marinelli theme and it displays everything else just fine.
Here's the view, located in a sidebar, looks fine:

Clicking the link....

What am I missing?


texts:
The dependency core/jquery.ui is not loading into the theme. jQuery is loaded as it is included by default but jquery.ui refuses to load.

#theme.libraries.yml
popup:
  version: 1.x
  js:
    js/popup.js: {}
  dependancies:
    - core/jquery
    - core/jquery.ui

#theme.info.yml

libraries:
  - theme/popup

I have also tried attaching the library using the code below, but still no luck.

// theme.theme
function theme_page_attachments_alter(&$page) {
  $route = \Drupal::routeMatch()->getRouteObject();
  $is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);
  if(!$is_admin) {
    $page['#attached']['library'][] = 'theme/popup';
  }
}

I have seen multiple references to core/jquery.ui throughout drupals files. So am a little confused.

I feel like i must be missing something obvious.

jQuery UI will load in fine if you are logged in, but again i believe this is included by default for admin users.


texts: How do I find out which module loads which javascript file?

texts:
I have been experiencing script related problems and would like to go through all the script files by disabling/enabling, to find out which is causing the problem.

So I'd like to be able to find out which module loads which javascript file. Then I can go by enabling disabling the modules.

How can I do that?


texts: How to automatically modify a field after saving content?

texts:
I have posted this question on drupal.org (via a comment titled "field modification triggered by saving action"), but I realized that the thread is more than five years old. So I reproduce here the question made there:

field modification triggered by saving action

I need to modify a field, but this change has to be triggered when saving the term and it depends on the value of another field, let me explain ...

term

field 1: filled with options A/B/C
field 2: <info>random_name

I save and if value in

Field 1 is A, then value in Field 2 must change to "Source: random_name"
Field 1 is B, then value in Field 2 must change to "Destination: random_name"
Field 1 is C, then value in Field 2 must change to "Product: random_name"

Note that the label <info> is the one that must change.


texts: Why is my link field not aliasing my path when the link is for the current node?

texts:
I have a content type that includes a link field using the Link module. That content type is used to create nodes that will be displayed on a Basic Page using the Nodeblock module; I'm using them as navigation elements.

When I have a nodeblock with "about-us/careers" in the link field, when I'm on the "about-us" page the link in that node block correctly displays and takes me to "http://example.com/about-us/careers", but when I show that same nodeblock on the "about-us/careers" page the link is displayed as "node/id".

The link is being output in a custom tpl file using the l() function and the safe_value.

Has anyone else experienced this and do you know what's causing it and therefore how to fix it?


texts: How to run custom sql commands to database programatically

texts: I'm using MariaDB as database backend and I would like to use built in "Sequences" to get an integer number generator. I need to dinamically create sequences and get their values. Following this documentation I know the right sql commands to do it and I have tested it on MariaDB, but I haven't found a way to run this commands from Drupal 8 database connection object. I can only do selects, updates, inserts or deletes. How could I run this custom sql? I need it because I have to create custom sequences on submit some form.


texts: Get more drupal.org project usage information

texts:
Choosing a Drupal module has become an art-form.  Deciding if the module is active, used frequently, growing in usage, etc. is important.

I'm a site builder.  https://drupal.org/project/usage has lot's of good information but interested in levaring the view.  What kind of URL arguments are supported?  I know that:
?sort=asc will work, but can I filter by category, change time range or make a more sophisticated query?  I can add https://drupal.org/project/usage/webform and get more granular on a project basis but would like more control and to understand the URL arguments supported.

I didn't find any Project documents that were relevant.


texts: Computed field module: value of field when creating new content

texts:
for my content type I have this computed field code and when I update existing node everything is ok, but when I create new node, menu_get_object return empty values and drupal display this error message "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7562 of /var/www/dev/testpage/includes/common.inc)." and nothing was saved. When I used dpm() in devel it show me that after creating new content $node is empty, but when I update node created before everything is OK.

$node = menu_get_object();
$start_time = field_get_items('node', $node, 'field_start_time');
$start_time = $start_time[0]['value'];
$entity_field[0]['value'] = '$start_time';

thanks a lot for your reply


texts:
How can i make the second field visible depending on the value selected in the first field ?

i have tried this but it does not work :

 $form['call-to-actions-widget']['call-to-actions-widget_select'] = [
      '#type' => 'select',
      '#title' => $this->t('widget options'),
      '#description' => $this->t('choisir un widget'),
      '#options' => [
        'none'=>$this->t('none'),
        'year_navigation' => $this->t('exposed filter :year'),
        'row_max_unset' => $this->t('more publications ( block refresh )'),
        'internal_link' => $this->t('more publications ( internal link )'),
      ],
      '#default_value' => (!empty($config['call-to-actions-widget_select'])) ? $config['call-to-actions-widget_select'] : 'none'
    ];

    $form['call-to-actions-widget']['internal_link'] = [
      '#type' => 'textfield',
      '#title' => $this->t('internal link'),
      '#description' => $this->t('de type /node/56'),
      '#default_value' => (!empty($config['internal_link'])) ? $config['internal_link'] : ''
    ];

    $form['call-to-actions-widget']['internal_link']['#states'] = [
      'visible' => [
        [
          [':input[name="call-to-actions-widget_select"]' => ['value' => 'internal_link']]
        ],
      ],
    ];


texts: Phising warnings (in gmail) when using a gmail address as the website email address. How to avoid it?

texts:
I would like to use a gmail address (a simple email address. i'm not using google apps) as my website's email.

The problem is that users receiving messages from the websites (notifications etc..) have a yellow bar warning them that this might be a fishing attempt.

I thought there might be some settings or best practices to avoid this problem.

Any ideas ?


texts: How to avoid computed field to run on entity delete?

texts:
I have a computed field that does something based on field collection fields, saving the values in the database (standard behaviour).

The problem is that the code is ran also when the node is deleted, causing some errors on the site.

Is there a way I can intercept the operation (entity_delete) on my code so that I can provide a safe alternative on node delete (or, even better, the computed field is not ran at all) ?


texts: Search keys get variable is in subsequent search pages and so search not returning any more results

texts:
I have a small form that posts the search page. The resultant link is like this:

http://www.example.com/search/node?keys=test

Then subsequent searches don't work, because the form includes the keys variable in the form definition:

<form action="/search/node?keys=test" ...

This means that subsequent searches don't work. How do I fix this?

Another detail - If I type the search page directly into the address bar, i.e. www.example.com/search/node, I get "Your search returned no results" - suggesting it is doing a search just when accessing the page directly. I think this may be related to the issue, but I can't work out why it is occurring.


texts:
I want to create menu block for each user on sidebar.
In it there would be links like Videos, Images, Bio.

So i made view with argument and url is usertype/%/videogallery

It is working fine, but how can i add this as a menu item so when someone visits user3 profile the url in the block menu is leading to Videos, Images Bio with url usertype/user3/videogallery


texts:
Im quite new to drupal (7) and want to ask if there is a way that I can display a field from another content type to a field of another content type and applying condition at the same time?

Here is the scenario:

I have created content types: Courses and Course schedules

I will be creating more than 50 contents for courses (containing their description, objectives etc as fields).

I will create different course schedule contents (data in here changes regularly including fields like time, date, venue, etc).

What i want to accomplish is to display the course article with a field that is linked to the courses schedule content, thus showing the available class sched data for each course.

I dont want to do it with views because im thinking it would be tedious to create a view for each course.

Is there a best way you can recommended to accomplish this? or is there a module that does this?

Thanks so much for your time.


texts: How to remove the 'Reply' link in comments?

texts:
I'm currently using the following line of code in my comment.tpl.php file:

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

This also prints the 'Reply' link, but I'd like to remove that one. How can I do that?

Note: I'm able to hide the 'Reply' link with CSS, but that's not a very nice solution.


texts: Installing a profile inherited from an existing distribution

texts:
I would like to build a distribution based on the Standard profile coming with Drupal 7, by inheriting all the features of the parent distro and changing some of them with custom code.

The title of this question sounds very similar to "Is there a way to inherit a Drupal installation profile?". While the referenced post deals with building the code base, ie a .make file, here I am interested in site installation of a distro made of profilename.info, profilename.install and profilename.profile.

There is a solution proposed in [How to Write a Drupal 7 Installation Profile][2], that seems quite simple. So I tried the following code in mydistro.profile:

function mydistro_install() {
  include_once DRUPAL_ROOT . '/profiles/standard/standard.install';
  standard_install();
}

If this worked I could add custom features further down in the process.
Then I ran site-install with drush:

drush -d si mydistro -y --db-url=mysql://root:secret@localhost/mydistro_com

The process installs the database with 43 tables (out of 74 that come with the standard profile), and enables the following modules:

user, field_sql_storage, filter, node, field, text

and then throws this error message:

exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table                              [error]
'mydistro_com.block' doesn't exist' in C:\xampp\htdocs\mydistro.com\includes\database\database.inc:2171
Stack trace:
#0 C:\xampp\htdocs\mydistro.com\includes\database\database.inc(2171): PDOStatement->execute(Array)
#1 C:\xampp\htdocs\mydistro.com\includes\database\database.inc(683): DatabaseStatementBase->execute(Array, Array)
#2 C:\xampp\htdocs\mydistro.com\includes\database\mysql\query.inc(36): DatabaseConnection->query('INSERT INTO {bl...', Array, Array)

saying that the block table is missing. All other tables belonging to the modules that are listed as dependencies in standard.info are also missing:

dependencies[] = block
dependencies[] = color
dependencies[] = comment
dependencies[] = contextual
dependencies[] = dashboard
.
.
.

I have tested with Drupal 7.38 on Windows 7, php 5.6.2.

Same test and same result also with minimal profile.

Any idea about what I am doing wrong?


texts: How can I create a path auto pattern token based on a menu path without placing node in menu?

texts:
Here is the scenario:

We have a D7 multisite set up with an installation profile that we created so that all sites are basically managed with the same rules. But we do allow some flexibility... So we have a content type "News Article". Usually news articles won't be in the menu because there can be thousands of news articles on any given site. One site might want to put their news articles under the "News" menu item in the main menu. Some might call it "News Room". Since we're not forcing the parent path, I can't set "news" as a root path for all the nodes in path auto. And even more crazy, some site users might chose to place node A under News while node B is under About. I was thinking of some type of menu "parent" selector as if they were creating a menu item, without creating the actual menu item in order to generate the path. I thought the menu position module might be on the path I needed, but it turns out you have to create rules administratively and not on a per-node basis where the user is making the determination.


texts: Condition in variation product template is not triggered correctly (ajax caching ?)

texts:
I have a commerce project with a specific product type using an attribute to generate variation.
Variation product has two specific fields that I want to hide switch attribute.
I implemented hook_preprocess_commerce_product to check this. In my hook, I check for a variation in POST (purchased_entity) or GET (v=xyz). If no one is found, I retrieve the default variation and set into the $variables array a new value called "is_custom_variation". This value is set to TRUE when the variation is a "custom" one. Only one variation in a product can be a custom variation, other are standard variations.
The "add to cart" form use a "select" form element to (ajax) switch between variations.
In the product template (commerce-product--full.html.twig) I added the following code :
<article{{ attributes }}>
{% if is_custom_variation %}
  {{- product|without('variation_attributes', 'variation_field_1', 'variation_field_2') -}}
{% else %}
  {{- product|without('variation_attributes') -}}
{% endif %}
</article>

Strange thing appears when I test the code :

I load the product page with the default variation as "custom" variation : field 1 and field 2 are hidden. When I switch to another "non-custom" variation, fields are hidden too.

I load the product page with a "non-custom" variation : field 1 and field 2 are displayed. When I switch to the "custom" variation, fields are displayed too.

By enabling xdebug, I see that each time the template is called, the variable "is_custom_variation" is correctly set (TRUE on custom variation, FALSE otherwise)
Maybe anyone can point me what is wrong on my implementation... I don't know why the template is using always the same process after the first display. Is it related to ajax reload of the variation ?
Thanks in advance for any suggestion.


texts: Why this message "You are not authorized to access this page." coming on user edit page?

texts:
I am facing a strange behavior today, when I signup via Facebook or twitter and then go to user edit page it show this message:

  You are not authorized to access this page.

Even if try to access this page from admin login the same error is coming.
But if in signup via email then everything working fine.

I am using these modules as well LoginToboggan, HybridAuth Social Login.


texts: How does the theme folder work in drupal 7?

texts:
In Drupal 7, I would disable a theme within the admin section and i would physically rename the theme directory (from themeName to themeName_old), clear cache and restart the server, to my surprise, drupal 7 still picks up the theme (themeName_old).

The only only way i managed to get rid of a theme completely is by removing the the directory from the theme folder. Why is that?


texts: How to use a contextual filter value in a menu displayed on the same page

texts:
I use a view to display a list of books sorted by title. The view has a contextual filter to limit the list by topic. So, a link to the view might be /books-by-title/34 where 34 is the taxonomy term id for "self-help". The result is a list of self-help books in title order. Works great.

The user may also want to view the same books in popularity order, so I include a menu in the view header, one choice being "By Popularity". The menu link needs to be /books-by-popularity/34.

How do I pass the term id (34) from the URL into the menu link?

Seems like this should be easy, but after reading a dozen articles and trying several approaches, no success.

I should note that a given book be assigned more than one topic. For example, a "self-help" book may also be classified as being about "exercise". So I can't get the term id simply by looking at the topic field of the book.


texts: Dynamic Field Adition / Subtraction using FAPI

texts:
Goal Provide a user with a drop down menu defaulted to a value of none. Other options are the number 1 through 27. Based on the value select have drupal FAPI generate a fieldset that has anywhere from 1 to 27 required text fields. And should they then change their mind it would re-render accordingly.

What I have
So far I am able to get the FAPI to hide the field on initial form render however I can't seem to figure out how I'd take the selected array value and use that to generate out a new field set dynamically.

function single_add_ucm_form($form, &$form_state) {
$form['number_subscribers'] = array(
'#type' => 'select',
'#title' => t('How many subscribers are in the CUCM cluster?'),
'#required' => TRUE,
'#default_value' =>  0,
'#ajax' => array(
  'callback' => 'ajax_select_callback',
  'wrapper' => 'replace_subscribers_div',
  'effect' => 'slide',
 ),
'#options' => array(
  0 => t('none'),
  1 => t('1'),
  2 => t('2'),
  3 => t('3'),
  4 => t('4'),
  5 => t('5'),
  6 => t('6'),
  7 => t('7'),
  8 => t('8'),
  9 => t('9'),
  10 => t('10'),
  11 => t('11'),
  12 => t('12'),
  13 => t('13'),
  14 => t('14'),
  15 => t('15'),
  16 => t('16'),
  17 => t('17'),
  18 => t('18'),
  19 => t('19'),
  20 => t('20'),
  21 => t('21'),
  22 => t('22'),
  23 => t('23'),
  24 => t('24'),
  25 => t('25'),
  27 => t('26'),
  27 => t('27'),
),
);
$form ['subscribers_wrapper_container'] = array(
'#type' => 'container',
'#prefix' => '
',
'#suffix' => '
',
);

if (isset($form_state['values']['number_subscribers'])) {
$form_state >= 1;
$form['subscribers_wrapper_container']['UCM_SUB'] = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#title' => t('Subscriber IP Address'),
    '#required' => TRUE,
  );
}
}

function ajax_select_callback($form, $form_state) {
return $form['subscribers_wrapper_container'];
  }


texts: PDOStatement::execute takes 11s, what to do?

texts:
Our Drupal site is sslllooooowwwww, at best taking 3s for static-content pages, at worst 11s for shopping cart pages. Above is the profile for visiting the shopping cart. Profiling reveals that PDOStatement::execute is the #1 time consumer. Any advice why or what to do about it?

Not sure if indicator that my connection has problems, Drupal is inefficiently sending data, or if it's time to learn how to tweak MySql.


texts: Server connect time significantly increased over the time

texts: I run my web site on D7 with enabled Cache pages for anonymous users option Cache blocksis off. It works pretty fast for non registered users but I started to observe significant difference for registered users (they can create content and do other things) over 2 months. Server connect time has grown. What can be a reason for that and how can I fix it?


texts: Prohibit indexing aliases and original paths for search engines

texts:
For the same website two domains are used.

Would onedomain.com/node/100 be indexed by search engines for the alias onedomain.com/article/100 which is disallowed to be indexed by search engines in robots.txt? (onedomain.com/node/100 = onedomain.com/article/100)


texts: jQuery error "C is undefined" while making ajax call for pagination

texts:
I am using Ajax for pagination for a form in Drupal 6 project. It is working fine on my local machine with default theme but on live server it gives me an error and generates another pagination links below original one.

When I click on Next, Previous or page link it gives me an error "c is undefined
http://siteurl/sites/default/files/js/js_2ebf7f4036f86f9133a99317ed832acf.js/eval/seq/1
Line 1". Every time I click on link, it gives me the same error.

I have searched for some solutions, like http://drupal.org/node/846026, but they are not useful


texts: Anyone manage to work entity metadata wrapper with profile2 entity?

texts:
Code:

$profile = profile2_load_by_user($account);
$profile = $profile['main'];

$wrapper = entity_metadata_wrapper('profile2_type', $profile);

$wrapper->field_first_name->set(devel_generate_word(mt_rand(6, 12)));

I'm sure that $profile is Profile object. Beside 'profile2_type' I tried 'profile', 'profile2' but got error too.

Current error:

  Unknown data property field_first_name.


texts: How to fix this error in drupal: ajax: ajax.form.ajaxSubmit is not a function

texts:
I am creating a form with ajax submission in my Drupal custom form module.

When I click my submit button, I get the following error:

  ajax: ajax.form.ajaxSubmit is not a function.

I am searching some blogs, try something like uninstalling lightbox2 module, color box module, etc. But again the same error is displayed.

How can fix this error?

Note: I installed Lightbox first, but after this error I uninstalled it again.


texts: Watchdog reports many spammy looking page not found warnings

texts:
Periodically, I like to run the following command to see what kind of activity and errors are going on with our website in real time.

drush ws --tail --full

Every second or so, there is a page not found error, but the pages are things that have absolutely nothing to do with the content of our website, following our Drupal URL format. Our site has been migrated a few times and may have old content from a long time ago, but again, this content doesn't relate at all to our subject material. Does anyone know what might be happening or if this is normal?
How do I stop the command from running?

Thanks!


texts: Applying Patches to Drupal modules - How to deal with error messages?

texts:
I am trying to apply patch #110 from here in Drupal 7 - ViewsCalc.

I am following the instructions on this page: Applying patches on Mac OS X

When following the instructions, I get this error message:

Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/theme.inc b/theme.inc
|index 57d61ed..7db435b 100644
|--- a/theme.inc
|+++ b/theme.inc
--------------------------
File to patch:

What should I do?

I've tried giving it the path to the theme.inc file.  When I do this, it displays the following:

No such file or directory
Skip this patch? [y]

As a work around, I have installed Drush Issue Queue Commands and I have applied the following command in Drush:
drush iq-apply-patch 140665-#110

When I use this Drush command, I get the following error message:

Drush iq-apply-patch 140665-1: downloading patchfile                 [ok]
views_calc_grouping_140665-114.patch for project views_calc
Could not apply the patch with either -Np0 or -Np1; perhaps the patch[error]
was rolled for a different version of the project.

What am I doing wrong?

PS. I'm not sure if this is a valid question, as it deals with patching. However, it also deals with topics such as Drush so I believe it is on topic. If it is off topic, please could you direct me to the correct place to post it.


texts: Getting node user view permissions (Nodeaccess)

texts:
Is it possible to get node permissions through PHP. Like I load node id by ID and test it thru user ID. Is this user has permission to view this node or not.

I'm using nodeaccess module and I want to archive this through grants (assigning some users have rights to see and some not depending content). Calling something like if node page is ID = 12 (to get all project certain page). Then if it is I load some project nodes there (created new content type). I have to be sure, that viewer (account) has permission to see this data.


texts: Nodes containing simple field collection not displaying properly

texts:
I have a content type to which I added fields like description, image and a field collection containing two simple text fields. Editing and viewing in the backend (logged in as admin) works properly. But when I log off and go to the node it just shows the title and no more. Can anybody lead me to the right direction to find the error?

EDIT: If I leave the field collection fields empty, the other fields get displayed to other users, if I fill in something nothing shows up, just the title


texts: How can I use a Drupal 6 database in Drupal 7 without upgrading that database?

texts:
I am new in Drupal. Currently I am working on one project where I am using Drupal 7.12. My client had one project in Drupal 6 of which database he wants to use in the Drupal 7 project. I can not upgrade the Drupal 6 to 7 as it's a completely different instance but he wants to have same userbase and other things in the new project i.e Drupal 7. As per knowledge DB structure of Drupal 6 and Drupal 7 is very different and hence it's not going to be very easy to use the Drupal 6 DB in 7.

Please suggest me any way to use Drupal 6 DB in 7.


texts: How can I access to created "View modes" in views and create a block of it?

texts:
I created a "View modes" in Structure> Display-modes> View and I'm now trying to get access to it in views so i can be able to create a block of it.

By default in Drupal it's possible to create a block of teasers and full posts but I'm going to create a block of my own "View modes",

I cleared my cash several times but howsoever i try the "View modes" that's i created doesn't show in "Block display settings" dropdown menu and I can't create a block of it.


texts: Persistent session cookies: remember session even after closing the browser

texts:
I would like to store anonymous users $_SESSION in a cookie so that their cart and other custom information is still available even after closing the browser.

I found this interesting post which tells me I should add this to my local.settings.php:

ini_set('session.cookie_lifetime', 60 * 60 * 24 * 7);
ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 7);
ini_set('session.save_path', '/home/yoursite/sessions');

So that session cookie would be available for a week.
But it also stands that we should use session_regenerate_id() elseway the cookie lifetime is not updated.

I could not find session_regenerate_idin Drupal 7 source code, but I believe Drupal might already handle this from what I read in the code comments.

My questions are:

is this a good approach to have persistent cookie sessions?
do I need to add to my local.settings.php session_regenerate_id() too?

Thank you very much for your advises


texts: A views & CSS only solution for a previous post & next post buttons in a blog-node?

texts:
I found the Previous/Next API module that lets you create previous-post & next-post buttons, that you could put on any node.

For example, if you have nodes of the content type "Blog" you could put such two buttons under them in one div.

A core-only way would most likely include 2 view-blocks styled with some css (most probably display: flex; flex-wrap: wrap; etc).


texts:
I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field:

$file = file_save_upload('document', array(
    'file_validate_extensions' => array('txt doc'), // Validate extensions.
));

// If the file passed validation:
if ($file) {
// Move the file, into the Drupal file system
if ($file = file_move($file, 'public://')) {
  $file->status = FILE_STATUS_PERMANENT;
 // $file->file_display = 1;
  $file = file_save($file);

} else {
  $output = t('Failed to write the uploaded file the site\'s file folder.');
}
 } else {
$output = t('No file was uploaded.');
 }

I am attaching this file to the node using the following code:

$customNode->field_document[$customNode->language][0] = (array)$file;

When I call node_submit() function, I get the following error:

  Integrity constraint violation: 1048 Column 'field_document_display' cannot be null

Does anybody know what I am doing wrong?


texts: How can I get the metatag_config site name by consulting my db with php?

texts:
I want to obtain the metatag_config data through a mysql query with php from my db drupal, in order to obtain the site name, description, keywords and abtract.
How can I do it? Or where they are stored, then the config field of metatag_config returns something like this:

a: 7: {s: 5: "title"; a: 1: {s: 5: "value"; s: 26: "[node: title] | [site: name]";} s: 11: " description "; a: 1: {s: 5:" value "; s: 14:" [node: summary] ";} s: 8:" abstract "; a: 1: {s: 5:" value "; s: 14: "[node: summary]";} s: 8: "keywords"; a: 1: {s: 5: "value"; s: 38: "I am 502, News Guatemala, Guatemala";} s : 8: "og: title"; a: 1: {s: 5: "value"; s: 0: "";} s: 7: "og: type"; a: 1: {s: 5: " value "; s: 0:" ";} s: 6:" og: url "; a: 1: {s: 5:" value "; s: 0:" ";}}


texts: How to export private images from Drupal

texts: I want to export private images from Drupal to an external client. How to I authenticate an external client to access private files from Drupal DB?


texts: How to use hook_menu_link_alter() on taxonomy term view?

texts:
When viewing a taxonomy term, I want to change the 'Edit' link (in the admin tabs) to say 'Edit this term' instead.

In taxonomy.module, the menu item is defined like this:

function taxonomy_menu() {
    $items['taxonomy/term/%taxonomy_term/edit'] = array(
        'title' => 'Edit',
        'page callback' => 'drupal_get_form',
        // Pass a NULL argument to ensure that additional path components are not
        // passed to taxonomy_form_term() as the vocabulary machine name argument.
        'page arguments' => array('taxonomy_form_term', 2, NULL),
        'access callback' => 'taxonomy_term_edit_access',
        'access arguments' => array(2),
        'type' => MENU_LOCAL_TASK,
        'weight' => 10,
        'file' => 'taxonomy.admin.inc',
      );
}

So in my module, I try to do this:

function mymodule_menu_link_alter(&$item, $menu) {
  if ($item['link_path'] == 'taxonomy/term/%taxonomy_term/edit') {
    $item['link_title'] = 'Edit this term';
  };
}

After clearing cache and rebuilding menus, the menu item still says 'Edit'.

Is this because the menu item type is MENU_LOCAL_TASK? Or perhaps I am missing something else?


texts: Block not showing on a matching path (menu item duplicate)

texts:
I have a strange situation and would like to verify it with you.

I have a menu block of main manu level 2+ links.

Corporate     [<--block title, level 1 of Main Menu]
  About Us    [corporate/about-us]
  Services    [corporate/services]
  Contact Us  [corporate/contact-us]

It is configured to appear only for pages with addresses matching the pattern corporate/*. So far so good. But in order to better communicate the Contact Us page, I created manually a duplicate of the Contact Us (with the same [corporate/contact-us] alias) at level 1 of the Main Menu. Once that duplicate is there, the block disappears from the Contact Us page.

Is there a Drupal culprit I bumped into? Is there a workaround for this?


texts: Display Google Search XML results onto site within HTML

texts:
I have created a custom module to search the site using google site search and so far I have been able to get search results back in xml format and I need to have these results display on the site in HTML

Thanks for any help with this


texts: How do I add a node from a custom form using ajax? I want it to be submitted in the backend. How will it be if there are custom fields?


texts: How to add Span before my <a tag only for main menu 1st level items

texts:
I need to add a span tag before mt

if i add like

function mytheme_link($variables) {
  return '' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '';
}

it will add for all the menus

and if i use

function mytheme_menu_link($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }

  $link['localized_options']['html'] = TRUE; //let l function know that our link title includes html
  return ''.l($link['title'], $link['href'], $link['localized_options']).'';
}

it does not add at all.


texts: How do I show the result on same page after submitting the form?

texts: How do I show the result on same page after submitting the form in Drupal 8?


texts: Listing first name, last name at Users listing page

texts:
I have installed and configured User Profile module, which allows me to add fields like First Name, Last Name for users.

As of now, when I go to users list at /admin/user/user I see username column. How can I can add these extra fields in the column?


texts: Render a node as plain text for sending by mail

texts:
I like to use a node as mail body in Drupal 8. I have written a simple module which works fine except for output formatting:

function foo_notification_node_insert($node) {
  $type = $node->getType();
  if ($type === 'foo') {
    $to = 'test@examples.com';

    // passed to hook_mail
    $params = array(
      "node" => $node
    );

    \Drupal::service('plugin.manager.mail')->mail(
      'foo_notification',
      'notice',
      $to,
      'de',
      $params
    );
  }

function foo_notification_mail($key, &$message, $params) {
    $node = $params["node"];

    // subject
    $message['subject'] = "New node: " . $node->getTitle();

    // render body
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder($node->getEntityTypeId());
    $view = $view_builder->view($node, 'default', 'de');
    $message['body'][] = render($view);
}

If I understood correct $view_builder->view($node, 'default', 'de'); returns a render array. This one is rendered to HTML by render($view);. Drupal mail service converts HTML in message body to plain text. And that looks ugly.

Rendered mail body looks like:

---------------- My node title -------------------------------------
first field label
               first field value

      second field label
                second field value

      third field label
                third field value contains a longer text which break
at some point and is continued like this. Just for demonstration a
few more lines.
This ist how it looks like if it contains a line break. It's ugly.

The node has multiple fields and I like to use same view for representation on page (HTML) and in mail (plain text) - especially the order and formatting of node fields.

So what's the correct solution?


texts: How to display data export icon on top of an admin view without views-view.tpl.php in admin theme?

texts:
I want the XLS/CSV export link buttons of an admin view to be displayed on top of that view. If it weren't a admin view I'ld simply put a slightly changed views-view--NAMEOFMYVIEW.tpl.php into my default theme's template folder. But now I'ld have to put that template inside the core's themes folder to work on that certain view since this view has an admin path and is themed by a core theme.

I don't want to add anything custom to the core. Is there another way to bring that button to the top?


texts: Drush archive-dump override sql dump name

texts: Is there a way to use drush archive-dump but to pass it somehow the name of sql file it dumps into archive? Current name is too long (full path with dots instead / and # to separate path and site name) and not as useful so I would love to override its name (like I can do with tar.gz name with --destination parameter)


texts:
I'm currently in the process of updating our current site from Drupal 6 to Drupal 7. Between the designer guy and myself, we have been banging our heads trying to figure out where the extra large chunk of space below our footer is coming from. We have added two new regions and three blocks below our main content and when enabling the blocks, the space appears. We have tried everything we can think of. Any help would be greatly appreciated. Thank you.

The site URL is http://prosifland.webhost.uits.arizona.edu/


texts: See which context is used on a page when looking at the page

texts: When you are watching a page, is there a quick way for seeing all of the contexts that are being applied? Ideally I would like to be able to see which context is responsible per the blocks.


texts:
I'm working on a Drupal 7 site that has Simplenews and a custom registration process. The registration allows the user to subscribe to the newsletter, but once logged in there is nowhere to unsubscribe.

How do I go about creating a new page with features allowing the user to change their subscription?

I've search far and wide but can't get a concrete answer.


texts: How to order multiple values in a field collection

texts: I have an Content type which includes a field of type Field collection, of which there can be an unlimited number of values. I can't work out how to order the rows of data that are displayed by this field.


texts: Create Taxonomy term with added text and date fields, then display them in "add content"

texts:
I'd like to add a date field ("date") and a text field ("notes") to a taxonomy term ("Category").  Easy enough.

When I add content, I have the taxonomy term linked using term reference, and it is working fine.

What I can't figure out is this: I'd like the "date" and "notes" field to also appear on the add content screen once the "Category" is selected, and be fully editable.  How would I go about this?

Specifically, when I add content, I select the category and enter all other relevant data. I then enter a date and notes that apply to that node being created, and also apply to any other node of the same category.

Thank you for help!


texts: Running drush on pressflow (D6) + nginx server

texts:
SO, I have been using drush from past many years on an apache server and it has been working like charm. I have a multisite setup with Drupal and run around 100 subdomains. In my situation, I feel drush too easy to update certain things on the server for all subdomains.

Recently, we migrate our servers from apache to nginx(php-fpm) and also started using Pressflow instead of Drupal6. Since then I am unable to make any updates using drush on the subdomains. I run the drush command and it does not display any error, but also it does not do any updates on the subdomains. My server guy told me that drush is incompatible with php-fpm. IS that so?

Any ideas or solutions to make it working in a server running on nginx server and using Pressflow? If drush can't work, any links guiding how can I install a module on all subdomains using php would be great.


texts: Cancel function of AJAX fired from misc/ajax.js

texts:
How can I override Drupal.ajax written in misc/ajax.js?

I need to check URL existence before firing an AJAX call.

Is there any other way/better way to achieve that without overriding this js?

Thanks


texts: How would I add a section header sub-image based on path in Drupal?

texts:
A client has asked me to enter a graphic header (really a sub heading) on a site. This sub-heading graphic would fit nicely, side aligned into the header or leader region inside our subtheme based on Adaptive Theme.

I'm having a hard time figuring out how to best approach this.

1. Do I use Context based on Path?
That is should I detect the path in Context and use one reaction to place an image into the header or leader region. I'm assuming I'd have to code about 12 HTML blocks. Though this doesn't exactly sit right with me.

2. Use CSS logic
Since I insert the first path level into the body class, should I add a div to the header region called #sub-graphic and use the following CSS logic:

body.sub-section-alpha #sub-graphic {background-image: url('image-alpha.jpg');}
body.sub-section-beta #sub-graphic {background-image: url('image-beta.jpg');}

3. Other, better option
Am I not seeing a simpler way.

Caveat: I'd prefer a non-php solution but I am comfortable inside theme functions.


texts: How do I update core to only include security patches?

texts:
I have a old Drupal 7 installation and I would like to update my Drupal 7 to the latest release, but I know for a fact that some of my custom module will break on the latest update.

All I want installed is the security patches up to the latest Drupal 7. How can this be done or is it even possible without much effort? Also where and how can I view what is being patched during an update of Drupal 7 core?


texts: How to show Total with taxes at admin/commerce/orders when order status is Review (using Commerce)?

texts:
I need  to show Total with taxes at admin/commerce/orders using Commerce.
Here the orders are shown without taxes, how can get to show the total including taxes?
I didn't see anything like a Total with taxes in the view fields.

UPDATE 2 I need that the system show the taxes when the order status is Review It seems to me that the taxes are added when the status is Completed. or Pending. See my first capture.

Update 1: I also see that the taxes are not shown in admin/commerce/orders/XX nor in admin/commerce/orders/XX/edit. How am I supposed to see the taxes for the order?? This can't be right.

Capture with PENDING status


texts: Issues with namespaces and Migrate module migrating XML content

texts:
In the Migrate module I noticed that one reason I could not import an XML file was because it contained namespaces.  Removing namespaces from the XML file and Migrate class allowed me to import the content without issue.

In trying to fix this issue I came across this post which brought me to this patch for the xml.inc file (used to import xml sources) in the Migrate module.  Unfortunately it was for an outdated version of the module so I had to manually apply it.

The patch does not seem to work as I still get this error when attempting to migrate (the same error I was getting before applying the patch):

  Migration failed with source plugin exception: Passed variable is not
  an array or object, using empty array instead

I think I have tracked down where the issue is appearing in the xml.inc code, as this function, &xml, does not output $this->currentXml which should be a simplexml_load_file:

/**
   * Load and return the xml from currentUrl.
   *
   * @return SimpleXMLElement
   */
  public function &xml() {
    if (!empty($this->currentUrl)) {
      dpm('start grab url/xml');
      dpm($this->currentUrl);//it is grabbing this url ok
      $this->currentXml = simplexml_load_file($this->currentUrl);
      dpm($this->currentXML);//it is not loading the file properly it seems
      dpm('end grab url/xml');
      if (!$this->currentXml) {
        Migration::displayMessage(t(
          'Loading of !currentUrl failed:',
          array('!currentUrl' => $this->currentUrl)
        ));
        foreach (libxml_get_errors() as $error) {
          Migration::displayMessage(self::parseLibXMLError($error));
        }
      }
      else {
        dpm('register namespace');
        dpm($this->registerNamespaces($this->currentXml)); // this then fails
                                                           // to load since
                                                           // $this->currentXml
                                                           // is not populated,
                                                           // which is most
                                                           // likely generating the error
        dpm('endr egister namespace');
      }
    }
    return $this->currentXml;
  }

Here is the output when migration is run:

Is there something that would be stopping a simple php function such as simplexml_load_file to run here?  Or could this possibly not even be the issue?  There is currently an open issue with the Migrate module for this issue,  though there is not much activity on it.


texts:
We have a regular poll on our homepage, which I set up by selecting 'most recent poll'.

However, I want to add a different poll on a seperate page on my website. Can I do this? I can't find polls as a block or node function other than 'most recent poll'

Help?


texts: Drush up error - unable to untar - Destination already exsists

texts:
I have verified that the directory does not exist before attempting an update. The error I get is as follows.

Do you really want to continue? (y/n): y
Executing: svn info /home/sites/lg/public_html/drupal-7.26
Executing: bzr root /home/sites/lg/public_html/drupal-7.26
Executing: wget -q --timeout=30 -O /tmp/download_filexptX5V http://ftp.drupal.org /files/projects/drupal-7.26.tar.gz
Downloading drupal-7.26.tar.gz was successful.                                                                                [notice]
Md5 checksum of drupal-7.26.tar.gz verified.                                                                                [notice]
Mime type for /home/sites/lg/public_html/drupal-7.26.tar.gz is application/x-gzip                                                                 [notice]
Executing: tar -C /home/sites/lg/public_html -xzf drupal-7.26.tar.gz
Unable to untar /home/sites/lg/public_html/drupal-7.26.tar.gz.                                                                                [error]
Destination directory /home/sites/lg/public_html/drupal-7.26 already exists.                                                                   [error]
Project drupal was updated successfully. Installed version is now 7.26.

I am on a vps using CentOS 6.5
Drush version 5.9
Currently installed version of Drupal is 7.23


texts: Customising Search Box in Search Results Adding OnBlur and OnFocus Attributes

texts:
I am trying to add custom #attributes to the search_form in the search results page. I get the $form_id from devel which is $form_id = "search_form".

Here is my hook_form_alter() implementation:

function nm_form_alter(&$form, &$form_state, $form_id) {
    if($form_id == 'search_form' ){
    $form['search-form']['#attributes']['onblur'] = "if (this.value == '') {this.value = '".$form['search-form']['#value']."';}";
    $form['search-form']['#attributes']['onfocus'] = "if (this.value == '".$form['search-form']['#value']."') {this.value = '';}";
  }
}

I checked if the condition is right inside the if statement with the following code, but nothing happened.

dpm($form['search-form'])

So, I am suspecting that the if condition is right.


texts: How to solve the warning of CAPTCHA session resuse attack

texts:
I am using captcha module (7.x, 1.0 v), When i select the image & click on upload button. Then image uploaded successfully but show this warning message also.

How to solve this issue. Please help. Thanks.


texts: Loading in JavaScript that requires custom vars

texts:
I'm rebuilding one of my works modules from Drupal 7 to Drupal 8 and I'm 99% of the way there the one thing I'm stuck on is in some cases I need to load in a external library that changes on a users location and other which is defined in a settings form:

In Drupal 7 I'd simply do it with:

drupal_add_js($proto.'://f1.'.$region.'readspeaker.com/script/'.$customerid.'/ReadSpeaker.js?'.$srcparams,array('group' => JS_DEFAULT, 'type' => 'file', 'scope'=>'footer', 'preprocess' => FALSE));

But I'm not sure how to achieve this by creating a library in Drupal 8.


texts:
This is sample modal sample of boostrap modal

                <button type="button" class="close" data-dismiss="modal">&times;</button>

Modal Header

Some text in the modal.

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

and this is a line trigger modal in header.html.twig,

 {{ 'SIGNUP'|t }}

goal: open login form in bootsrap modal.

I find the name of file I can customize user-login block , it's block--userlogin.html.twig
then my markup

                <button type="button" class="close" data-dismiss="modal">&times;</button>

Login

                <form method="post" action="{{ path( "user.login" ) }}"   role="form" name="loginform">
                    {% if error %}

{{ "Could not login" }}

{{ "A valid username and password is required to login." }}

                    {% endif %}

                        <input type="email" value="{{username }}"   name="_username" tabindex="1" class="form-control" id="email" placeholder="{{ "username or email :"|t}}">

                        <input type="password" class="form-control" id="pwd" ame="_password" placeholder="{{ "Password"|t }}">

                        <input type="checkbox"> Remember me

                    <button type="submit" class="btn btn-default">{{ "Sign In"|t }}</button>
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
                </form>

                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

but with this action action="{{ path( "user.login" ) }}" it redirect me to user/login page.
I want to know how can I login/signup usuer ajaxly in modal without redirect to user/login page?


texts: Configuration syncronization not importing everything

texts:
I have a remote server which I initially setup with a default Drupal 8.7.7 install.  I have since been building the site on my local development server and would now like to transfer the developments to the remote server.

I exported the configuration using drush config:export

I committed the the exported items to git and pushed them to the remote server.  I then ran composer install --no-dev followed by drush updb on the remote server and logged in.
I then went to the configuration synchronization setting and clicked on the import all button.

Everything seems to be working fine however 12 items will not sync.  I have tried importing them via the import -> single item option and tried importing everything via drush cim, however the following items still will not sync and show no errors:

I have repeated the process a number of times to check it wasn't a one off error.

The only similarity I can see is that they are all core.entity_view_display settings apart from the one core.entity_form_display item.  Each one has different differences.

How can I debug why these items won't syncronize?


texts: Extend Search API: Create and expose custom sort/filter from db_table

texts:
I have a geocoded field for each node of a certain type. It simply geocoded the address filled in the node create form.

I've multiple views based on the search api (database not solr) and use facets on these views to filter them.
I do not want to change anythiong about the facets, I just want to sort the view by distance based on the geolocation values I already have for them.

How do I extend the search_api module and expose my db_table to it (after modifying the values to work out the distance relative to starting point).

For some strange reason search api does not even allow sorting with the most basic of fields, such as node title =/

see: http://drupal.org/node/1422942


texts:
I'm using theSocial media module to share in linkedin, facebook. I have installed the Widgets module. I want to include this to created field 'Linkedin_share'(image type).

Shall I need to add separate field for share? How to include this social media in view page.


texts:
I'm trying to use Drupal Queue and Cron to execute a task.
In the following example I:

select all the users
create an item in the queue for each of them
define the function that has to be run for the items of the queue

What happen is that at some point the system stops running the queue and the only way to start again the process is to kill it. (I'm using Ultimate cron to controll Cron processes).

I understood that after some time the system should stop the script and start it again at the following cron job. Am I wrong?

Here there is the code:

 function mymodule_cron() {
        $sql = db_query("select u.uid, u.mail FROM {users} u WHERE u.status=1");

    $queue = DrupalQueue::get("testlogging");

    $number_of_rows = $sql->rowCount();
    if ($number_of_rows > 0) {
        foreach ($sql as $record) {
            $queue->createItem($record);
        }
    }
}

function mymodule_cron_queue_info() {
    $queues = array();
    $queues['testlogging'] = array (
      'worker callback' => 'log_user',
      'time' => 300,
    );
    return $queues;
}

function log_user($record) {
    watchdog('MyModule', 'queue info: uid = ' . $record->uid . " " . $record->mail);
    sleep(2);
}


texts: How to get the view count of taxonomy term pages in Drupal 8?

texts:
I'm running Drupal 8.3. Statistics module can count views of a node. But is there a way to find out view count of taxonomy term pages?

I'm looking for how many times a taxonomy term page is viewed, but not the count of how many times a taxonomy term is used in nodes.

Edit:
In short, I'm looking for a similar module as below for Drupal 8.  https://www.drupal.org/project/taxonomy_term_statistics


texts: Views with one exposed filter not returning all results?

texts:
I need a bit of help with a simple view I have: I created a custom content type, imported about 900+ nodes into it, set up a view with Input Required + Exposed Filter based on the title + Ajax. The Exposed filter uses "contains".

It's working for the most part but some of the nodes don't come up, i.e. if you search "eggs" nothing comes up. Here's the view http://www.ovwrc.com/waste-lookup and you can see that "Eggs" exists as a node. http://www.ovwrc.com/waste-lookup/organics-green-cart/eggs .

I don't have any filters on the view except for 1. Is Published, 2. Is content type "Trash".

I have the problem with other items but I can't figure out the pattern for the effected items in order to troubleshoot.

EDIT: Thanks to help below, we've isolated it to views not returning results if the "body" field is empty. This is where I'm stuck now.


texts: Is there a better way to get a uid in a block than using Input Format PHP?

texts:
I need to make a direct link to page which needs the uid in the URL.

Can someone suggest a better way to do this in a block? Does Input Format PHP code open some unnecessary attack vectors? Are input filters or tokens in blocks possible?

<?php
global $user;
?>
.
.
.

   <a href="/user/<?php echo $user->uid ?>/fboauth?destination=stream">Facebook Deauthorize

This is a legacy site running 6.28 using FBOauth.


texts: 8 - Caching for custom blocks doesn't work on

texts:
I'm working on a project based on Drupal 8.3.x . It comes with cache already enabled which is great if we know how to customize it. I've been going through the different tutorials and I was able to implement the following cache for my custom block:

$build = [
      '#cache' => [
        'tags'=>['node'], // Invalidate cache whenever a new node is created/modified/deleted
        'contexts'=>['url'] // Invalidate cache per url
      ]
    ];

The problem I'm having is my website depends on cities and display different content for different cities.
I have the following scenarios:

When I visit www.example.com/city1 the block should display nodes from city 1
When I visit www.example.com/city2 the block should display nodes from city 2
When I visit www.example.com the block should display the nodes from the latest visited city

With the snippet above I'm able to make the point 1 and 2 work. however when visiting front only the content of the first visited city appears, which make sense because the Invalidation of the cache depends on the url and  is only 1 url.

I tried this but didn't work:

global $selected_city;
'#cache' => [
    'keys'=>['home_slider_'.$selected_city],
    'tags'=>['node'],
    'contexts'=>['url']
  ]

Where $selected_city is coming from the cookie or the request depending on separate logic.

Is there a way to Invalidate the cache per url + global variable ?

EDIT: The answer below fixes the issue for authenticated users but doesn't fix it for anonymous users. Any help with that would be appreciated.


texts: Cant display error message in custome form!

texts:
I have create one form which have two fields.

$form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#maxlength' => 20,

    '#required' => TRUE,

);
$form['phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone'),
    '#maxlength' => 20,
    '#required' => TRUE,
);

In page.tpl.php file displayed both fields. Now i have press submit button without enter any value in text box error message will displayed.

But in my page.tpl.php file cant display error message!

How can i show all error message?


texts: Display a view with exposed form programmatically

texts:
I show a view in my own module, like this: $viewFromDrupal = views_embed_view('storage', 'block');. The view is showing up, but the exposed filter is not working when I place the included view directly after an other view.

When the view $viewFromDrupal is showing at the top of the page the exposed filter works correctly.

Does someone have some experience with this?

Should I include some extra files or something?


texts:
I have simple Image field, its file path is set to field/image so when you upload a file, its path is something like /sites/default/files/field/image/image.jpg.

But when I create content and upload the file, first of all, the thumbnail preview doesn't show up and when saved, the image is not loaded, because for some reason it's calling a wrong path of sites/default/files/styles/large/public/field/image/image.jpg.

But why? Why that path? There's no such path. Who is calling the wrong URL? It should call the correct path where the picture was uploaded and that's /sites/default/files/field/image/image.jpg.

I've tried using "Original Image" for the image field display, instead of the "Large" style, but no matter what I use, /styles/large/public/ is added to the URL.

Permissions are correct on the /sites/default/files folder (the original image is uploaded successfully), there are no related errors in the dblog report, and there's no problem with GD/Imagemagick in the status report.

What could be adding the extra part to the image URL?


texts: In Drupal 7, how can I include a CSS file only when the front page is being viewed?

texts:
I'd like to include a particular CSS file only when the front page is being viewed, since it only applies to the front page, and it's a relatively large file. I know that the solution will involve using drupal_add_css(), but I'm not sure where in my theme's template.php file this would go. Is there a particular hook within my theme that I should be implementing to use this? Thanks.

EDIT: I essentially have the code down, I'm just not sure what hook is available to my theme files to implement. The actual code will look something like...

if (!strlen(request_path())) {
    drupal_add_css(drupal_get_path('theme','mytheme'). '/css/front.css');
}


texts: After I overrode a block template for a primary links, block-edit-link doesn't show anymore...?

texts:
I just created block-menu-primary-links.tpl.php file in the root of my theme, in order to strip off some default structures I have for other blocks, but now that I did that, block-edit-link which was displaying itself by default on hover, doesn't appear anymore. It's not that I want it to back, but I just wonder why did it go away and how can I control it?

UPDATE:

Here is what I have in my block-menu-primary-links.tpl.php:

<div id="block-menu-primary-links">
    <?php echo $block->content; ?>
</div>

When I inspect html structure after it is rendered I see that contextual links are in there, but hidden and obviously block has lost something that made the logic tick.


texts:
I working on project where user search for nearest shop. so configured view and output result  user get list of shops. in that result I want to provide a button Email us and when user click on that button have to one form will appear and user fill up the data and click on SEND, Then that mail should be send to the shopkeeper`s mail id and also to the user who sent it.
I want to display a button on every single result with fetching mail field according to user into webform
I used profil2 for user profile and  webform modules.


texts: How to translate plural strings with Drush?

texts:
If we want to translate a plural string in Drupal we can use the format_plural() function.

If you are programming drush commands you can use the dt() function to translate strings, but if you want to translate plural strings in drush wich is the function to accomplish this?


texts: Ultimate Cron installation Table 'db_name.ultimate_cron_log' doesn't exist

texts:
After installing the ultimate cron module version 8.x-2.0-alpha4,
When I navigate to (/admin/config/system/cron/jobs), I get the following error meassage -
Base table or view not found: 1146 Table 'db_name.ultimate_cron_log' doesn't exist: SELECT l. FROM {ultimate_cron_log}* l WHERE (l.name = :db_condition_placeholder_0) AND (l.log_type IN (:db_condition_placeholder_1)) ORDER BY l.start_time DESC, l.end_time DESC LIMIT 1 OFFSET 0; Array ( [:db_condition_placeholder_0] => system_cron [:db_condition_placeholder_1] => 0 ) in Drupal\ultimate_cron\Entity\CronJob->loadLatestLogEntry() (line 526 of modules\ultimate_cron\src\Entity\CronJob.php).
Drupal\Core\Database\Statement->execute(Array, Array) (Line: 640)
I have tried uninstalling and installing it again, but the error persists.
Kindly help.


texts:
I am utilising Services to open up some login resources on my site and as a result if multiple users incorrectly try to sign in the entire external website will be blocked because of flood control.

Is there a way to add an IP whitelist to the flood so that there can be an unlimited number of requests from those IPs without them being blocked?


texts:
Attempting to install Drupal 7.16 (also attempted 7.12) onto my local machine, I get the following error at the database stage.

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Looking at the Drupal database with PHPMyAdmin, I see the "variables" table is created, together two columns; that is all that gets created prior to the error.

I can't find a single solution to this.

EDIT

Solved - found the drupal installation script andreverted the mysql engine back to MyISAM


texts: yml settings file is just read on module install

texts:
I have a config/install/module_name.settings.yml with some configuration values needed for my module. Now while developing the code I need to change or add values to the file. But for the script to be able to access the information I need to deinstall and install the module each time.

Is this normal?

I guess the yml file is just read on install; afterwards, the values are stored in database.

How should I store configuration data without needing to reinstall the module each time?


texts: Proper way to delete Images uploaded in Image fields

texts:
What is the proper way, through code, to delete images on an entity?

I have a cron function that processes like so:

function processQueuedPropertyPhotoset($entity, $photos) {
if (!is_array($photos)) {
  watchdog('mymodule', 'Trying to process photos for a property but it has no photos. Aborting.');
  return;
}

if (is_array($entity->field_property_image) && count($entity->field_property_image)) {
  foreach ($entity->field_property_image['und'] as $key => $value) {
    $photo = file_load($value['fid']);

    if ($photo) {
      file_delete($photo, TRUE);
    }
  }
}

// wipe clean the records in the field_ table

unset($entity->field_property_image);
$entity->save();

// rest of code processes and saves new images

I am curious if this is the proper or effective way. Also, do the image derivatives generated get cleaned out by Drupal this way too? I notice there is a 'deleted' field in the database on the Image field table definition. When is this ever used?

This method cleans the entity data, removes the images from the server and files table. I am simply curious as if is an acceptable method that covers all the bases in Drupal or if there is an API function to simplify this. This function is called daily when we run a third party integration web service.


texts:
Is there a way for a view to pull out x number of nodes of the same content type but use a different theme function for each one depending based on the value of one of its fields?

I need each node to be themed according to a field which will have the name of a theme function.


texts:
I need to create a block with eg the latest comments on the site.
when using views, concegui select the data I wanted, but the problem is that I need to edit the output of view (specify the html). I tried to make a tpl, but the fields when they get to this, are already formatted ([#markup]). also tried to make a block programmatically by accessing the fields of view, via $comments = views_get_view('last_opinions');, but so the fields do not bring content, but for example, ids (for referrals), or integers (in the case of dates), ....

basically, how to change views output?


texts:
I've a strange problem with Date formatting in Chinese.

The 年 string has to appear after year(for example 2013年). The string appears in all years before 2013 and also in 2013. But if it is future year(2014, 2015 etc) then it doesn't appear.

This is the date format used.

Y\年 n\月 j\日

I am not sure if it is Drupal's problem or PHP's. And I have no clue how to debug this issue. Any kind of hint is most welcome.


texts:
How can I remove a menu item when admin is logged in?
I used the following code but it doesn't seem to work.

function mymodule_menu_alter(&$items) {
     $items['item_x']['access callback'] = 'mymodule_menu_access_callback';
     $items['item_y']['access callback'] = 'mymodule_menu_access_callback';
}
function mymodule_menu_access_callback() {
  global $user;
  if ($user->uid == 1) {
    return FALSE;
  }
  return TRUE;
}


texts: Drupal gives `Notice: Undefined index: highlighted in include ..` error during theme creation

texts:
So, I have a fresh instal of Drupal 7.34 and decide to create a simple theme.

I created a folder in /sites/all/themes/samayo and in it, I placed a screenshot.png, style.css, samayo.info inside samayo.info I pasted these settings.

name = samayo
description = samayo theme
version = 0.2.1
core = 7.x
engine = phptemplate

screenshot = screenshot.png

regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[footer_content_1] = Footer Content 1
regions[footer_content_2] = Footer Content 2
regions[footer_content_3] = Footer Content 3

stylesheets[all][] = style.css

Went to drupa and chose this them as default, and I am getting this error for the past 2 hours.

Notice: Undefined index: highlighted in include() (line 126 of /var/www/public/dev.samayo/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_first in include() (line 138 of /var/www/public/dev.samayo/modules/system/page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 144 of /var/www/public/dev.samayo/modules/system/page.tpl.php).
Warning: include_once(/var/www/public/dev.samayo): failed to open stream: No such file or directory in _drupal_theme_initialize() (line 209 of /var/www/public/dev.samayo/includes/theme.inc).
Warning: include_once(): Failed opening '/var/www/public/dev.samayo/' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in _drupal_theme_initialize() (line 209 of /var/www/public/dev.samayo/includes/theme.inc).

All the answer I checked do not seem to affect anything, including this which suggested placing

regions[highlighted] = Highlighted

in the samayo.info file, but even this could not change anything.


texts: How do web search engines handle view pages?

texts:
When search engines are examining the content of a Drupal site how do they identify content assembled by a view?  A single view can have unlimited pages associated with it. In fact the entire content of a site can be provided that way.

Any resources on how these engines do their job in general (and for Drupal specifically) would be appreciated.


texts: How do I allow users to see other users' views based on taxonomy fields

texts:
I have a bunch of nodes called 'article' with a taxonomy field attached called 'publication'

I have also added the 'publication' field to the user so he/she can choose which publications they want to see - they select these and then there's a view where they can only see their own selection, based on a contextual filter.

Question is, how can I let users select the option to see other users' chosen publication view. Can this be added to their setting page, along with the actual publications - /user/1/edit?destination=admin/people


texts: Views Slideshow, white backround when hover

texts:
I'm using drupal 7,views slideshow and views slideshow cycle modules, I have a white background color when hover on the slide, I can't remove it or find their css selector in chrome webdeveloper.

Help me please.


texts: What are some quick ways to setup Product Displays in Drupal Commerce?

texts: What is a fast way to create product displays in drupal commerce? Say I created 50 different unique products and now they are all over the place on the product list, how can I intuitively add these 50 products to a product display?


texts: How to provide the ability to upload media to the server?

texts:
I want to provide the ability to upload PDFs/mp3s etc. to the server.

What is the best way of achieving this?

I've seen the media plugin but it seems that replaces the upload field rather creating a stand-alone media area? Or maybe it does?


texts:
I've a form with couple of buttons, on submit it redirect to third party site for authentication.
On the submit I want to load that inside iframe on same page. How I can do that?