texts: Is it possible to build a site without Users and Node?

texts:
It's hard for me to imagine any site that could be built without the Users and Node modules.  Having them as modules makes it possible to replace them with alternatives, I suppose, but they are so fundamental to how Drupal works that I would suspect that anyone who wants different behavior would probably just skip Drupal altogether, since replacing these might break most of the other modules you might use.

Is it possible to build a Drupal site without Node and Users?  Has it actually been done, or is it just a theoretical possibility?


texts: Set username to the field firstname untill the field first name is filled

texts: I am using profile2 module for user profiles and created a profile with first name and last name fields which are used for configuring real name. And I have set real name as page title. But there is machine name being displayed if the first name and last name fields are empty. I want to set user name to the first name field until the profile fields are filled. is there anyone who knows the solution?


texts: Ubercart change product image thumbnail in cart view to a different field

texts:
When you install ubercart, there is a product image field that is used by default. The field is labeled uc_product_image. I decided not to use this field for different reasons, but now I notice that none of the images for products are showing in the cart as thumbnails. I found and changed the field in the views I could, but I can't find where to change it in the actual cart.

Any help on where or how to change this will appreciated.


texts: In Yosemite not able to generate the styles folder, I upload the project in a ubuntu test server, and it works

texts:
I know this is a question related to permission. The only thing I have changed in my environment is that I upgrade to Yosemite, I check apache everything is working fine.

This question has been asked in here and in others. I checked every possible solution. Here is what I have done:

Change the permission in every possible way  even to 777 in local environment. It still gives the error
Change the apache user to my username and staff group, and make sure I have the set the right user and group
Clear the cache every time that I make a change
Use drush to flush the image as recommended in here

I have uploaded my site to a ubuntu server. It generates the files perfectly there without any trouble. Any ideas what it is happening in my local machine that it is not generating the styles folder and give an access denied error? I can upload files btw, it is just not able to create the folder styles and its files.


texts: Override node.tpl.php for the Front Page

texts:
I am trying to override the front page node, however after following the guide from the official site, it's not working.

Guide: https://www.drupal.org/node/1585528

I have taken node.tpl.php and renamed it to node--front.tpl.php and made changes to the layout, saved and cleared cache. The changes are not being displayed.

Now if I edit node.tpl.php directly it shows the changes, anyone know what I am doing wrong to override specific node templates?

EDIT:
I want to move the title below the image being displayed in the front page.

See below: Moving the title block under the content block, moves the title down as I want it to do, however how do I specify this for just the front page and not all nodes? (renaming node.tpl.php to node--front.tpl.php does not work as mentioned above)

In node.tpl.php: (title block)

<?php print render($title_prefix); ?>
<?php if (!$page): ?>
  <h2<?php print $title_attributes; ?>>
    <a href="<?php print $node_url; ?>"><?php print $title; ?>

<?php endif; ?>
<?php print render($title_suffix); ?>

(content block)

<div class="content clearfix"<?php print $content_attributes; ?>>
<?php
  // We hide the comments and links now so that we can render them later.
  hide($content['comments']);
  hide($content['links']);
  print render($content);
?>


texts: Is it possible to update Drupal page cache right after it is cleared?

texts:
I am trying to improve Drupal performance and I have all the tuning usual suspects setup:

Varnish
Memcache
APC
Drupal core cache

From what I understand when you clear the Drupal cache it does not replenish page caches until an anonymous end user makes a request for the page. Drupal then builds the cache and the following page requests are snappy. The problem with this is the non cached call can take 2- 4 seconds to finish. We would like all page requests to be as snappy as a cached request. So we are looking into either a way auto replenish or set up a cron that would hopefully make the non cached page request before an end user.

If my assumptions are correct is there a module or way to automatically replenish all page caches? I am assuming that since this does not automatically happen that it is potentially a resource issue to cache the entire site at once. But if we set Drupals cache to live for 1 or 2 days and cleared cache on a cron in the middle of the night it might be ok to automatically replenish. Has anyone ever tried to solution this?


texts: A lot of core JavaScript files not being included

texts:
For some reason a bunch of core JS files are not being loaded. I've had to manually add them in with a module hook_js_alter function like so:

function MYMODULE_js_alter(&$js) {
    drupal_add_js('misc/jquery.js', array('group' => JS_LIBRARY, 'weight' => -100, 'every_page' => TRUE, 'scope' => 'header'));
    drupal_add_js('misc/jquery.once.js', array('group' => JS_LIBRARY, 'weight' => -99, 'every_page' => TRUE, 'scope' => 'header'));
    drupal_add_js('misc/jquery.cookie.js', array('group' => JS_LIBRARY, 'weight' => -98, 'every_page' => TRUE, 'scope' => 'header'));
    drupal_add_js('misc/form.js', array('weight' => 19, 'every_page' => TRUE, 'scope' => 'header'));
    drupal_add_js('misc/collapse.js', array('weight' => 20, 'every_page' => TRUE, 'scope' => 'header'));
}

The only core JS file loading by itself is drupal.js, and a bunch of module scripts. Other than that I had to include the 5 above myself, otherwise various parts of the public site and admin areas were not working.

This works, but it feels really sketchy. And previously I had only included the first 3, until I noticed more admin form stuff breaking. So I hate to think that there may be MORE scripts that I will only discover missing through trial and error.

Any ideas why they are not being included??

UPDATE

I've narrowed it down, there are two custom modules which are breaking it. One of them is much simpler than the other so I'll just try to figure that one out first. This line of code, inside the .module file, and not within any function, is causing the issue ($form_js is a string containing JavaScript)

drupal_add_js($form_js, array('type' => 'inline', 'scope' => 'footer'));


texts: How can I imitate the features of Node Reference and Node Reference URL in Drupal 8?

texts:
In Drupal 8 we do not (at least currently) have the Node Reference and Node Reference URL Widget modules. How do I replicate their features?

I have a content type, let's say 'Book'. I also have a content type of 'Review'. Right now, the 'Review' content type has a reference field to 'Book'. A user can create a new 'Book' whenever they want just fine. Using the beta Form Block module for Drupal 8, I've embedded the node create form for 'Review' so that a user can create a new review from the bottom of the 'Book' page.

How can I have that newly created 'Review' automatically set the 'Book' as its reference node? Understandable I haven't seen a Drupal 8 module for it so I don't mind writing some code but I don't know where to start.


texts: How can I create a relation between a number of related pages and a main event?

texts:
I need to create mini-site within existing website. I have new content type called Events.

Single event will be number of pages related to that event. Some of the pages that will be under single event are:

Registration
Scheadule
Sessions
Resources
Travel

All of this pages needs to be on their unique url like mysite.com/event-name/registration. My first guess is to create all these as different content types and create some relation to single Event.

So my question is: How to create a relation between these pages and a main event? Since this mini-site needs to have its own navigation menu, can I automatise this menu creation somehow or should I create a separate menu for every event.


texts: How to display the form submission results in a custom page?

texts:
How to display the form submission results in a custom page or a view ?

I want to display it in a custom style with table , and want to do custom php coding too .

where i have to create custom page , or is there need a custom module for this ??


texts:
How can I have a JS confirmation button pop-up when a user clicks a button and then fire the #ajax defined for that button?

Right now, I have this button at the end of my form:

    //add an update button to the end of every row
    $form[$row_name][sizeof($data['columns']) + 1] = array (
        '#type' => 'button',
        '#value' => t('Delete Row'),
        '#name' => $row . '-_udr_delete_data',
        '#prefix' => "",
        '#suffix' => "	",
        '#ajax' => array (
            'callback' => '_udr_ajax_handler',
            'progress' => FALSE,
         ),
        '#weight' => 1001,
    );
  }
  $form['table_end'] = array(
      '#prefix' => '
',
  );

  //if the form has been changed, update the appropriate fields
  if ( isset($form_state['triggering_element']) ) {
    $callback = _name_to_callback($form_state['input']['_triggering_element_name']);
    if ($callback == "_udr_update_data") {
      _udr_update_data($form, $form_state, $data);
    }
    elseif ($callback == "_udr_delete_data") {
      _udr_delete_data($form, $form_state, $data);
    }
  }
  return $form;
}

I would like to make this button make a pop-up warning that asks the user if he/she would like to really delete the data.  If yes, then delete.  If no, then don't delete.

I have tried various methods such as:

'#attributes' => array('onclick' => 'if(!confirm("Really Delete?")){return false;}'),

And also:

    // Add an delete button to the end of every row
    $form[$row_name][sizeof($data['columns']) + 1] = array (
      '#type' => 'submit',
      '#submit' => array('udr_submit_rebuild'),
      '#value' => t('Delete Row'),
      '#name' => $row . '-_udr_delete_data',
      '#prefix' => "",
      '#suffix' => "	",
      '#ajax' => array (
        'wrapper' => "row-$row",
        'callback' => '_udr_ajax_handler',
        'progress' => FALSE,
      ),
      '#weight' => 1001,
    );
  }

  if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] == t('Delete Row')) {
    $form[$row_name][sizeof($data['columns']) + 1]['#value'] = t('Really Delete?');
    $form[$row_name][sizeof($data['columns']) + 1]['#submit'] = array('udr_submit_handler');
  }

  $form['table_end'] = array(
    '#prefix' => '
',
  );

  //if the form has been changed, update the appropriate fields
  if ( isset($form_state['triggering_element']) ) {
    $callback = _name_to_callback($form_state['input']['_triggering_element_name']);
    if ($callback == "_udr_update_data") {
      _udr_update_data($form, $form_state, $data);
    }
    //~ elseif ($callback == "_udr_delete_data") {
      //~ _udr_delete_data($form, $form_state, $data);
    //~ }
  }
  return $form;
}

function udr_submit_rebuild($form, &$form_state, $data) {
    $form_state['rebuild'] = TRUE;
}

function udr_submit_handler($form, &$form_state, $data) {
  $callback = _name_to_callback($form_state['input']['_triggering_element_name']);
  if ($callback == "_udr_delete_data") {
    _udr_delete_data($form, $form_state, $data);
    $form_state['rebuild'] = TRUE;
  }
}


texts: how to give path to custom page tpl for content type

texts:
I want to give the path for custom page tpl which I have created for specific content type. 'test_insights' is my content type name.I have created custom page tpl in the folder

project_name/themes/themename/templates/page--test_insights.tpl.php

I want to know how to give the path for created tpl now I tried http://localhost/project_name/test_insights

I caught the error as

  The requested page "/project_name/test_insights" could not be found

.


texts: Hide field results not matching exposed filter

texts:
I have an Autocomplete (Tags style) field with multiple values in the field.

I'm using exposed filters to display nodes with one or more values in the Autocomplete field matching the filters.

I want the node field to display only the matched values, not all of them when rendered in a view.

For example. Say I have three nodes with the following field values:

Then I apply exposed filters of Orange and Grape. This results in the following (as Node A does not contain these values):

What I want is values not in the exposed filters to also disappear, so the user can see exactly what selected fields matched the node. Like so:

I assume this can be done using the Global PHP field, but really need some help to figure it out.


texts:
Is there an easy way to always show the "read more..." link when text is trimmed in a view?

Was looking for an "Always show read-more link" option for cases when the text is not long enough to be trimmed, but there is none unfortunately. :(

Any suggestions?

Thanks!


texts:
I need a (D7) block print the main menu in the footer; It's not clear to me how the pieces fit together:

We implement block_info, block_view, a pre-process function and a template.

function MODULE_NAME_block_info() {
  $blocks['my-footer-menu'] = array(
    'info' => t('My Footer'),
  );
  return $blocks;
}

function MODULE_NAME_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'my-footer-menu'
     $tree = menu_tree_page_data('main-menu');
     $block = array( 'subject' => t('My Footer'),
                  'content' => theme('my-footer-menu', $tree),
      );
    break;
 }
return $block;
}

function MODULE_NAME_theme() {
  return array(
    'my_footer_menu' => array(
    'template' => 'my-footer-menu',
    'variables' => array('tree' => NULL),
  ),
);
}

function template_preprocess_my_footer_menu(&$variables) {
  $variables['tree'] = menu_tree_all_data('main-menu');
}

<?php
  for ($i = 0; $i < count($tree); $i++) {
    $menu = each($tree);
     if ($menu) {
        $link = array( '#theme' => 'link',
                'title' => $menu[1]['link']['link_title'],
               'href' => $menu[1]['link']['link_path']);
          print '' . $link['title'] . '';
        //  $output = theme( 'links', $link);  //this isn't right
        //  print $output;    //returns an empty string;
        }
      }
 ?>

The above gets the top level menu items on the page, but it's not clear how to get to the children of each menu item.   Sorry if it seems a bit muddled, just trying to cut my way through the weeds here.


texts: How do I add a class to a panel page's body element without having to add it manually in the variant configuration section?  I want all panel pages to have a body element with the class 'panel-page'.  Is there some kind of hook like hook_panel_page()?


texts: How do I create a view that uses data from an external site

texts:
I have a site that needs to get articles data from a view in site A in order to display these articles as a view in site B.

I found the module Services Views, which i don't completely understand.
I have installed it in site A, and created a services resource of a view with services display.

But how do I create a view in site B that displays the articles using that services endpoint?


texts: Integration of Custom entity with relationship of views

texts:
I have created a custom Entity with few properties like uid, title etc. I have made the entity fieldable so that I can add more fields to my entity. Using this, I have added 2 reference fields.

Also have exposed the entity in a view so that I can render the content of the entity using view.

function notification_entity_info() {

  $services['notification'] = array(
    'label' => t('Notification'),
    'base table' => 'notifications',
    'entity keys' => array(
      'id' => 'notification_id',
      'label' => 'title',
    ),
    'entity class' => 'NotificationEntity',
    'uri callback' => 'entity_class_uri',
    'controller class' => 'NotificationEntityController',

    'admin ui' => array(
      'path' => 'admin/notification',
      'controller class' => 'NotificationEntityUIController',
      'menu wildcard' => '%notification',
      'file' => 'notification.admin.inc',
    ),
    'module' => 'notification',
    'access callback' => 'notification_access',

    'fieldable' => TRUE,
    'bundles' => array(
      'notification' => array(
        'label' => t('Notification'),
        'admin' => array(
          'path' => 'admin/notification',
          'access arguments' => array('administer notification'),
        ),
      ),
    ),
    'views controller class' => 'EntityDefaultViewsController',
  );
  return $services;
}

If I add a Relationship to use the fields of the Reference field, then the content of the Entity is only visible to Administrators only. Users of other role are not able to see the content of the view.

/**
 * Access callback for Notification CRUD operations.
*/
function notification_access($op, $NotificationEntity = NULL, $account = NULL) {
   if ($op == 'view' && user_access('view notification', $account)) {
     return TRUE;
   }
   else if (user_access('administer notification', $account)) {
     return TRUE;
   }
}

Can someone guide me with what I am doing wrong? Do I have to do anything special to make it work?


texts: Creating "view" of "user blogs" specific to a user

texts: On a user "my account" page, I want to create a view block which lists the blogs created by that user only. Is there a way to accomplish this ?


texts:
Is there a way to organized entity deletion by braking into different batches? I have 700.000 entities associated with pictures that I would like to delete and I would like to perform that into batches.
Any how to?


texts: Installing Drupal on an all-Nginx server - OOB or should you customize / replace any file?

texts:
When one downloads Drupal, she gets several .htaccess files with it. These files contain Apache directives written in the Apache variant of the Perl Compatible Regular Expressions (PCRE) language holding server, as well security related configuration directives.

My question can actually be comprised of the following 2 questions, and I ask these as one who plans to move working with a VPS and got many recommendations instilling Nginx on it (if I'll use it, I would want it to be the sole server, and not just a reverse proxy as it seems to me the best way to develop familiarity with it, in the long run):

Should or can Drupal 8 work out-of-box with Nginx?
Where are the Nginx parallel to .htaccess (and to any other Apache conf file, if there is one) in the Drupal instillation and if there aren't any, how can one know how to construct them? I ask as I try to understand if one must be a PCRE genius for constructing these in case they don't come with Drupal.


texts: How can I add the Schema.org type 'BreadcrumbList'?

texts:
I want to add the Schema.org type BreadcrumbList for my website.

I have installed Schema.org module, but I'm unable to find any option there.

I tried using the Easy Breadcrumbs module, but it does not have the Schema.org type BreadcrumbList.

I have checked on the Schema.org website and there in example given for JSON-LD.


texts: How do I add fields to the email field contact form?

texts:
Using Drupal 7, I have a content type that uses the email field module(CCK) so that the page author can enter an email address for readers to mail them. With display suite module together with views contact form module, the saved page displays the site wide contact form. The emailed responses are delivered to the email address that was entered by the content author. That works great.

I wanted to add extra fields and managed to do this with the code below which I  added to the template.php file but the code only works with the site wide contact form on example.com/contact

My question: How can I add those fields to the email field module's contact form as well?

This is the code I'm using to include the fields in the contact form display:

function MYTHEME_form_alter( &$form, &$form_state, $form_id ) {
if( $form_id == 'contact_site_form' ){
    $form['message']['#weight'] = 6;
    $form['copy']['#weight']    = 7;
    $form['phone'] = array(
        '#type' => 'textfield',
        '#title' => t('Phone'),
        '#required' => TRUE,
        '#weight' => 4
    );
    $form['province'] = array(
        '#type' => 'textfield',
        '#title' => t('Province'),
        '#required' => TRUE,
        '#weight' => 5
    );
}
}

This is the code I'm using to include the field responses in the email that gets delivered:

function MYTHEME_mail_alter(&$message) {
if ($message['id'] == 'contact_page_mail' ||
$message['id'] == 'contact_page_autoreply') {
$message['body'][2] = t('My Phone Number') . ': "' . $message['params'][phone'] . '"';
$message['body'][3] = t('My Province') . ': "' . $message['params']    ['province'] . '"';
}
}


texts:
I have a form that I want to override title of textfield. I managed to do that with this snippet in _form_alter function

$form['some_wrapper']['email'] = [
  '#type' => 'textfield',
  '#title' => t('Change this title'),
];

Wondering if i could just override this with some method like setValue?


texts:
I need to know how many blocks in the region! is there any short way to do that ?
if more than one block in the region than I want to add custom class to region.


texts: Enable wysiwyg on textarea summary field

texts:
Anyone know how I can enable the WYSIWYG editor for the textarea summary field in D8? I have a "body" field on my news content type set to "Text (formatted, long, with summary)" but only the main textarea gets the WYSIWYG editor while the summary field is just a standard textarea.

The summary field does support rich text, presumably using the same text format as the main textarea, but it's not clear since CKEditor is not there.

Note there's a similar question asked but it's from 2011: How to enable WYSIWYG in a text field summary?


texts: Views contextual filters programmatically alter add to or

texts:
I have 2 fields in my contextual filters. Obviously, the default join is AND but I'd like to filter on one or the other field depending on which one of two arguments is provided.

I tried the following approach:

function mymodule_views_query_alter(&$view, &$query){

    if($view->name == 'my_links'){
        switch ($view->current_display) {
            case 'page_2':
                // dsm($query, 'Query');
                $query->where[0]['type'] = 'OR';
            break;

            default:
                # code...
            break;
        }
    }
}

However, using the devel module to inspect the Views data, the type field in the where section of my View still outputs AND instead of OR.

Which means my attempts to alter my View is not working.

Can anyone help me get this working?


texts: Can one domain be hosted on two drupal instances?

texts:
I have a huge Drupal 6 site, and a small, newer partial version of the site on Drupal 8. Instead of migrating, we decided to build a brand new site from scratch.

Is it possible to host the site such that:

http://www.sitename.com takes user to --> new D8 site

http://www.sitename.com/topic1 /topic2 takes user to new site.

http://www.sitename.com/topic3 /topic4 (everything else) takes user to old D6 site?

Thanks!


texts:
I am trying to implement hook_library in my custom module.  To help narrow down the problem, I wrote a dummy module with just the following two functions:  hook_views_api and hook_library.  I put a dsm statement in each of the hooks, to test whether the hook was getting executed.  The hook_views_api hook is getting executed but not the hook_library hook.  Anyone see what I am doing wrong?

I have tried clearing the cache.
I have tried uninstalling and reinstalling the module.

Here is the code:

// hook_views_api
function mymodule_views_api() {
  $path = drupal_get_path('module', 'mymodule') . '/views';
  dsm ("inside mymodule_views_api");
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'mymodule') . '/views',
  );
}

// hook_library
function mymodule_library(){
  dsm ("inside mymodule_library");
  return array();
}


texts: Putting any fields of referenced entity in lightbox frame

texts:
I want output a field as a link to an overlay that has fields of a referenced entity in it.
I can output the actual link just fine as long as it doesn’t have to be an overlay.
Content type A is called ‘performance’, content type B is ‘performer’ (to which is being referenced).

So, for now, in my view there are only two fields: ‘Performer name’(of content type B also the title) and ‘title’ (of content type A). ‘Performer’ is arranged above ‘title’ and display set to none. ‘Title’ has ‘ouput field as link’ checked and has the token in the URL that is the title of ‘Performer’.

So this makes the link that is the title in the view go to the node of the performer that is referenced in the ‘Performance’ node.

I know that in the ‘rewrite results’ fieldset, I can fill in ‘lightbox2’ in the ‘rel’ attribute of my link. When I do this though, the lightbox shows, but is empty. No image, no values of any field, no nothing.


texts: Exclude first node with specific value from a view?

texts:
We have an Article content type. The content type has a boolean field called "Featured".
We have two views setup:

The featured article view. This is limited to the most recent article with the "Featured" boolean checked (limit 1, sort by date).
The recent articles view. This shows all the recent articles on the site.

The problem is we don't want the most recent "Featured" article to display in the recent articles view. But we also want other "Featured" articles to display if they aren't the most recent.
I can't find an easy way to achieve this as we are only allowed to filter out ALL featured articles or none, and not just the first one.


texts: How to add a user/login Link to the Maintenance Mode page?

texts:
I have my site in Maintenance Mode. I know I can get to my login page by going to http://example.com/login .

My client wants a login link on the Maintenance Mode page (when in this mode). Before I say "no this is not possible", I am wondering if this is possible. I could add this to the Maintenance template page right? I already have a custom Maintenance Mode page.

EDIT: Where the http://adaptivethemes.com/how-to-theme-the-user-login-page-in-maintenance-mode
solution works, its not what I want. All I want is a link to the user login page displayed on the Maintenance Page.

I did try this: I added html to the maintenance php template:
Login

HOWEVER this only show a link that was NOT clickable. Also how would I get to the User login page if I am testing this on a test server, but the domain will be different than on the test server. Change the domain once on the production server?


texts: How to I add specific meta tags to panels pages?

texts:
I have panels pages, and I need to set specific meta tags per page.  The meta tags module lets you set up defaults, but I need specific tags per URL.

I can't seem to find this anywhere.


texts: Taxonomy field not visible for anonymous users with content create permission

texts:
When creating a new node, anonymous users can't see taxonomy field but administer can see it.anonymous users have permission to create nodes.

How can I show it to anonymous users?


texts: Total count of two different content types in one View?

texts:
Use case: How many Demonstrations and Deliverables are from each State?

I'm using a View with Aggregate but don't see a way add multiple content type counts.

Refer to screen capture of the page and view settings please.


texts: How to migrate using explode with occasional empty array

texts:
We've made a migration from the City of Helsinki's Linked Events API, and during this work we've been seeing these migration messages:

  Array index missing, extraction failed

Here is an example of an event that works nicely:
https://api.hel.fi/linkedevents/v1/event/hko:14004/

And one that causes the error:
https://api.hel.fi/linkedevents/v1/event/matko:16134/

In the latter you see that offers is returned as an empty array. We're using the skip_on_empty plugin to handle those:

field_offers_is_free:
  -
    plugin: skip_on_empty
    method: process
    source: offers
  -
    plugin: extract
    index:
      - 0
      - is_free
field_offers_info_url:
  -
    plugin: skip_on_empty
    method: process
    source: offers
  -
    plugin: extract
    default: false
    index:
      - 0
      - info_url
      - fi

The problem is that never reaches the skip_on_empty plugin. I've been stepping through this in the debugger based on my findings I created an issue in Drupal Core https://www.drupal.org/node/2905929

When Get sets $multiple to true, processRow() in MigrateExecutable runs a foreach () on an empty array - resulting in the skip_on_empty plugin to be skipped.

Is there something wrong in our setup or did I uncover a bug? Any ideas on how to work smoothly around this?


texts:
I want the outgoing mail that is sent by my custom module to be in HTML, but I dont know how.

This is my submit function:

//create an array from the companies in the db in a comma separated list
$companies = db_query("SELECT companies FROM {offer} WHERE id = $id")->fetchField();
$companies = explode(',', $companies);

// Set some variables
$from = 'noreply@danielholm.se';
$subject = 'Sent mail';
$module = 'mymodule';
$key = 'mykey';
$language = language_default();
$params = array();
$send = TRUE;

// the data
$question = db_query("SELECT message FROM {offer} WHERE id = $id")->fetchField();
$name = db_query("SELECT name FROM {offer} WHERE id = $id")->fetchField();
$mail = db_query("SELECT mail FROM {offer} WHERE id = $id")->fetchField();
$phone = db_query("SELECT phone FROM {offer} WHERE id = $id")->fetchField();
$compname = db_query("SELECT compname FROM {offer} WHERE id = $id")->fetchField();
$comptype = db_query("SELECT comptype FROM {offer} WHERE id = $id")->fetchField();

// Sort the companies
foreach($companies as $company) {
        $message = drupal_mail($module, $key, $company, $language, $params, $from, $send);
        // Create the mail content
        $message['subject'] = $subject;
        $message['body'] = array();
$message['body'][] = 'THe HTML MAIL HERE';

        // Retrieve the responsible implementation for this message.
        $system = drupal_mail_system($module, $key);

        // Format the message body.
        $message = $system->format($message);

        // Send e-mail.
        $message['result'] = $system->mail($message);

        // Update table where sent to 1
        $update = db_update('offer')
            ->fields(array(
            'sent' => '1',
            ))
            ->condition('id', $id, '=')
            ->execute();

        // Set message of performed action
        drupal_set_message('Done');
        $form_state['redirect'] = 'admin/content/offer';
        cache_clear_all();
}


texts: What is the benefit of making sub theme in drupal?

texts:
I have created a sub-theme of a theme in Drupal 7. I have done all changes to create this and it is working fine. But I am confused what actually it is for, what are the benefits of making this?
I know the differences between base theme and sub-theme but I need more information why we create sub-theme.


texts: caching issue after updating records into database

texts:
I've developed leave management in drupal 7 but facing an issue. When leave balance is updated due to calculations then it not shows right value from database due to drupal caching. Once I clean all caches then it shows right values. Is there any way to stop caching or update caching?

Please do some help.


texts:
How can tracks downloads of private files attached to nodes via the core upload or contributed filefield modules for custom content type, I created a file field and I simply want to count the number of times have been downloaded this file and display this count number in node template?

My Project purpose:

Upload a file as Admin, or any authenticated user
Store the file in a private directory (But accessible by public
users)
Allow the all people or anonymous users to download the files.

These are some details about my content type module.

Module name: My Module
Content type name: My Content
Field Type: File
Display Format: URL to file (or Generic)
Field name: field_file

I know that there are some module like:

File download count
Download Count
AJAX Download Counter

For drupal 7, but seem  none of them work in drupal 8.

Thanks for any help.


texts: Use the Services-3.x node resource to create a new *unpublished* node

texts:
Is there a way that I can force a node to be unpublished by using the
node resource?

Requirement: Site A defines a content type 'item' which is published
by default. Site B needs to create 'item' nodes on A, and these
auto-created nodes should be unpublished.

function toolreq_test_create() {
$toolreq_endpoint = variable_get("toolreq_endpoint", "");
$options = toolreq_service_login();
if (!is_array($options)) {
    print "error<p>";
    return;
}
//create a node

$node_data = array(
                      "title"=>"DHC Tool 04 dev",
                      "type"=>"item",
                      //"status"=> FALSE, //ensure unpublished
                      "status" => 0,
                      "language" => "und", //lanugage neutral
                      "field_webpage"=>array(
                                                  "und"=>array(0=>array("url"=>"http://berkeley.edu",)
)
)
);

//use json
$options['headers']['content-type'] = "application/json";
$options['method'] = 'POST';
$options['data'] = json_encode($node_data);
$request = drupal_http_request($toolreq_endpoint . '/node', $options);
}

Since the node table's status field is the mysql INT type (with a
default of 1), I would think that I could pass status=>0 in the above
code, but doing that results in a published node. I have tried passing
0 using both JSON and x-www-form-urlencoded data.

If I use status=>FALSE and use JSON, the node is created as
unpublished, but I think that this is equivalent to inserting '' in the node.status field which results in a mysql warning:

mysql> INSERT INTO `bamboodirt`.`node` (`nid`, `vid`, `type`, `language`, `title`, `uid`,
`status`, `created`, `changed`, `comment`, `promote`, `sticky`, `tnid`, `translate`)
VALUES (NULL, 21, 'item', 'und', 'sql insert test', '0', '', '0', '0', '0', '0', '0', '0',
'0');
Query OK, 1 row affected, 1 warning (0.03 sec)

mysql> SHOW WARNINGS
+---------+------+----------------------------------------------------------+
| Level   | Code | Message                                                  |
+---------+------+----------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: '' for column 'status' at row 1 |
+---------+------+----------------------------------------------------------+

I would live with that warning, but my webhost's mysql is less
permissive and I get a real error (durning node_save() I think) on
that server:

"SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'status' at row 1"

(Here's the thread over at Pantheon http://help.getpantheon.com/pantheon/topics/json_node_create_works_on_localstack_fails_with_error_500_on_pantheon.)

Is there a way that I can force a node to be unpublished by using the
node resource, or do I need to write my own resource?


texts: Script exits on drupal_bootstrap_full when run from system cron

texts:
I have a script that imports data into custom entities created in a drupal 7 database. It needs to run daily so i've added it to my system crontab (running CentOS 6.7). The problem i am having is that when it's run from cron (the script is executable and there's a symlink to it added in /usr/sbin) it runs but fails when the drupal bootstrap is run.  It works flawlessly when run from my user id, the service account user id, another persons id, and on so i know that the script is written correctly. There is no error reported to the console (grabbing std_out and std_err output in my cron command) and there are no php errors logged.  I am at a loss of where to look for the answers i need to find out why it's failing.  I assume it's something to do with the environment when run from cron but i've confirmed the shell is bash as expected and i'm not using any environment variables that aren't set explicitly within the script.  Where can i look for more answers?

Here's My crontab:

55 16 * * * svc_load cs-import >> /var/log/import-log-`date "+\%Y.\%b.\%d"`.log 2>&1

Here's the relevant lines to load drupal from my script.  I see all the echo's print out except the last "drupal loaded". I even tried an or die() after the bootstrap function but it didn't do anything, there must be a crash of some sort that aborts the script before php can process the die() function.

// Drupal Connectivity
echo "Start Loading Drupal\r\n";
define('DRUPAL_ROOT', dirname($parent_dir)."/httpdocs");
echo "Set Drupal Root\r\n";
require_once (DRUPAL_ROOT.'/includes/bootstrap.inc');
echo "Included Bootstrap.inc\r\n";
drupal_override_server_variables();
echo "Overrided Server Variables\r\n";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
echo "Drupal Loaded\r\n";

I have PHP logging on, here's the relevant lines from php.ini but the file size never increments when I run this script (it does on other errors).

log_errors = On
log_errors_max_len = 1024
error_log = /var/www/vhosts/dev/logs/php_errors.log

Thank you in advance for any help you can provide!
~Lindsay


texts: How to migrate content using a web service with multiple calls?

texts:
I need to migrate content from a web service to which I have to call several URLs. A call to receive a list of nodes and then a call for each node to receive information from the fields.

Something like this:

Calling domain.test/webservice/

<results>
  <count>10</count>
  <list>
    <id>100</id>
    <id>101</id>
    <id>102</id>
    ...
  </list>
</results>

Calling domain.test/webservice/101

<results>
  <id>101</id>
  <name>Name</name>
  <field1>Field example</field1>
    ...
</results>

So, in my migration yml file I have something like:

source:
  plugin: url
  data_fetcher_plugin: http
  headers:
    Accept: application/xml
  data_parser_plugin: simple_xml
  urls: https://domain.test/webservice/

How can I specified the migrate process to retrieve each content info from a URL like https://domain.test/webservice/[ID]?


texts:
I am building a module on drupal 8 to make a redirection after a form is submitted

function form_redirect_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'ptt_contact_form_blocks_submit';
}

function ptt_contact_form_blocks_submit($form, FormStateInterface $form_state) {
    $form_state->setRedirect($route_name);
}

but for the setRedirect, it needs to have the route name. Like if i want to redirect to node/24, then how can i find the route name of the node?

Thanks!


texts: Omega subtheme - Dropdown menus not working properly

texts:
When on http://demo.drupalizing.com/?theme=corporateclean the source for About menu item is:

About

Our Team

Our Vision

However, on my site, when on the homepage, the source for Privacy (a menu item which has pages hanging off it) is as follows:

Privacy

It's only when I am ON the Privacy page, that the dropdown menus appear when I hover over the Privacy menu item. The source now is:

Privacy

Advice

Complaint management

What am I doing wrong, and why aren't the dropdown menus being displayed when on the homepage for example, but instead only when I am ON that page?


texts: jQuery UI filter, Full HTML and hook_block_view_VIEW_NAME_alter

texts:
I have installed jQuery UI Filter and jQuery plugins to get text with accordion effect. It works perfectly when the content is inserted in a node, with a special tags language. However, when I try to get the text rendered in a block with hook_block_view_VIEW_NAME_alter, as I am just the $data["content"]["#markup"] property, it is not working and it is displaying the special tags without rendering them: [accordion], etc.

Must I get the effect by using clean jQuery instead of the modules? Is there a way of saying that I want to apply the "Full HTML" properties to the content-markup text of the block?


texts: node_save is not same as saving a node manually

texts:
I've removed many terms from a vocabulary and now I see this error when I see a node referencing the deleted term(also the attachment):

EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7693 of D:\xampp\htdocs\gij\includes\common.inc).

I know it is an issue( like this) which goes away if I edit and save the node manually but does not work out if I run this code from Drush:

$node = node_load($nid);

 if ($node !== FALSE) {
  print "Saving the $full_path\n";
  node_save($node);
  }

Why this difference?


texts: Select list set default value does not work

texts:
I have referenced filed, which works like select list, I want first value be always default value in content edit page. Now N/A is always selected.

function theme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

  $form['field_my_name']['und']['#default_value'] = 1;
}

This is my code, but it does not work


texts: Force nodes created by Feeds module to be published even if nodes are unpublished by default

texts: How can I do this? Force nodes created by Feeds module to be published even if regular nodes are unpublished by default.


texts: Solve "Cron run failed" without Watchdog

texts:
Some years ago i wanted to turn off watchdog because it's memory and db consumption, but today i need info about why my cron isn't running because need to use Search module from now?

Trying to run cron manually (admin/reports/status/run-cron) return

  Cron run failed.

calling /cron.php and running from server's command line has no return,

How can i debug this?

or

There is any other way to turn on logging?

  admin/settings/logging/dblog

has no return

SELECT * FROM `watchdog`

MySQL returned an empty result set

function watchdog()

still there in bootstrap.inc

settings.php and .htaccess free from any relevant "error", "watch", "dog", "bdlog", "repor" keywords (have no php.ini)

  /modules/dblog/dblog.module

still untouched. XML sitemap and Search is disabled

No logging, no cron, i am puzzled. Thanks for any help.


texts: Menu list links of different languages of a Localized Menu are shown in all languages?

texts:
I have a menu which is set to Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized.

The in the menu I have several links in english and spanish languages.

In the frontend regardless the language I select all links of the menu are shown. ie: if I select english the spanish links are also shown.

What am I missing here?


texts: Fatal Error when enabling In-Place Editor in Panel

texts:
When enabling the in-place-editor in a panel and then visiting the page with the panel I get the following error: Fatal error: Class 'panels_renderer_editor' not found

In the log file there is entry saying:
Plugin editor des Plugin Tpys panels: display_renderers refers to a nonexistent file:
sites/all/modules/panels/plugins/display_renderers/mlpanels_panels_renderer_editor.class.php

and that's true!
The mlpanels module with this file is outside of panels module in a separate directory.

What is wrong?


texts: How to change base url protocol to HTTPS?

texts:
I wanted to update the protocol of my base url to HTTPS. I have added nginx configuration to redirect all http requests to https.
But in meta tag, when I choose [site:url], it returns a http url, http://www/example.com

How do I change the base url protocol in my website?
I used a third party tool to analyze my site SEO performance. As per the report, there are http href links in my website like http://www.example.com/search, http://www.example.com/user. These are search menu and user profile pages. How do I fix it? How do I tell my drupal that my site's protocol is HTTPS and base url should be https://www.example.com ?


texts: CKEditor tabber shows tabs to the right on the screen when logged in as admin

texts:
I have reported this question with the CKEditor tabber issues, but I thought I ask this question here too, in case I am missing something obviuos... I have installed the CKEditor tabber module and after creating some tabs and tab content, the tabs is pushed out to the right in the screen. Like this:

I noticed that when I log out the tabs appear above the content as expected. I have narrowed it down to the permission "Use admin toolbar". When the admin toolbar is shown, the CKEditor tabs is showed as on the image. When the admin toolbar is not shown, the CKEditor tabs shows as they should above the tab content.

I have spent hours trying to find how the toolbar affects the CSS in this way, but I can't figure out what to do...

Anyone?

UPDATE: I noticed that the "left" attribute is 100% too large in this section that is in charge of the first tab's positioning and width:

<dt id="tab-0-0" class="current style="width:16,6667%; left:100%;">

In the js file semantic-tabs.js this code is in charge of the above:

$(this).css({
  'width': (100 / numTabs) + '%',
  'left': (100 / numTabs * tabIndex) + '%'
});

So, if I add "-100" after tabIndex above the tabs are positioned correctly when logged in with the admin toolbar visible. If logged out the tabs are pushed to the left in this case. So the JS decides to add 100% to the "left" value when the toolbar is visible. Also I can see that for half a second the tabs are positioned correctly before being pushed out, every time I refresh the page. I am going crazy here...


texts: Make my view the default for content type

texts:
I am probably doing this the wrong way, so please correct me if I am wrong!

I have created a new content type, called "Entities". My content type has many fields, and the default view when you visit "/node/123" is ugly, and doesn't permit much customization. So I created a new View with all my fields displayed exactly how I want, and set the path to be "entity/%", so when you visit "/entity/123" you get my new, prettier version.

However, the default view at "/node/123" still exists, and is the default display when you click on a link in the search results, or admin interface, etc.

How can I make it so "/entity/123" (my view) completely replaces "/node/123" (default view) everywhere? Eg. becomes the default view for the "entity" content type?


texts:
I would like to build a form, and print it in a block via hook_block().

How can I do this?


texts: Display the Group Title after the content in Views Grouped By

texts:
I've got a View which displays a grid of content. The nodes are of type Photo Gallery and I'm showing a grid of thumbnails, each thumbnail representing one node. I'm grouping the content by Post Date so it appears like this:

There are two galleries posted on 09/04/2013, 1 gallery on 09/01 and 3 galleries on 08/28 and this is all well and good. However, my client would like the group title to appear below the content. So it should show Rome 2 and Rome 2013 and then below that should show Post date: 09/04/2013.

Is there any way I can make the group title render after the content instead of before?


texts: How to make the blog post ascending order?

texts:
By default (without Views), the blog posts are sorted by date: the first post is the latest date.

I need the first post, is the oldest.

How to achieve this without Views?

Also I have a custom module to execute an override of blog_page_last() function (I followed the steps in this page). But it does not work. It does nothing, nothing at all.
Also directly I modified the blog_page_last function() in File: /modules/blog/blog.pages.inc. And nothing happens.

Thank in advance.


texts: How to implement a simple shopping cart without Commerce and Ubercart?

texts:
I need simple solution for shopping cart without big monstrous modules like a Ubercart or Drupal Commerce. I've a small site (catalog) with a few products. I need add to each of them an Add to cart button, cart block and page (can be made using Views). Checkout must be just a form with few a fields (like Name, Address etc), which can be made using Webform.

Why Commerce and similar modules are not good for me: I don't need specific fields like SKU, product displays facilities, online payments, registration for user, tax calculation and other. I just want to keep it all simple.

Any suggestions?


texts:
It looks like I went a bit too overboard with number of features modules on my website (~50), but it really made initial development easy (for multiple people). Now the question is - what would be a safe procedure that would allow to merge them into less number of beefier features?

Is creating those new ones with "Allow conflicts to be added" option, and then disabling and UNINSTALLING the smaller ones safe? Should I firstly enable conflicting new modules? What is the order and procedures?


texts: Cache Backport not loading correctly. Unable to change cache.inc location?

texts:
Drupal 6, trying to get the Cache Backport module working. Every time I load a page, this error fires:

Call to undefined function _cache_get_object() in /var/www/sites/all/modules/cache_backport/cache_backport.admin.inc on line 60,

That is defined in cache.inc within the cache_backport module's folder. It would appear that the file isn't being loaded. Here's the relevant portion of my settings.php file.

$conf['cache_inc'] = 'sites/all/modules/cache_backport/cache.inc';

Simple enough.

I'm using the Domain module and looking around the config files, I did notice references to cache but I can't really tell their purpose. Also, and this may or may not be related, but prior to trying the cache backport module I tried just doing the Drupal 6 memcache module and it never seemed to send anything to it. The memcache area in Reports would load, it was communicating with Memcached, but it never seemed to write anything to it. I feel like it was caused by the same thing.


texts: Node Reference to include an "Apply Now " link

texts:
I'm looking for answers to the best approach to dynamically including an "Apply Now"/"Apply For" link/button within node content.
For example. the content node has been custom created and visitors (registered users only) can click the "Apply Now" once viewing any said published node. For example, this maybe a "Join Band" on a music band collaborative site, a "Apply Now" on a Jobsite, a "Date Me" on a dating site, "Tender Now" on a contract site etc.

I've also schematicised in LibreOffice Draw for basic work-flow and using the Panels/Ctools/Rules combination along with Relation to ensure that posted content appears in a Users dashboard (based on their profile2/HomeBox type) whereby application Receivers can manage/reply/on-hold/delete such application notices. Or maybe I'm barking up the wrong tree in my approach!?

My Main issues is primarily the inclusion on an "Apply Now" link in any said node and the most effective and futureproof so looking for for clarification on best D7 tools/Modules to use for such a back-end integrated task.

The entry here relates further to my question: Re: Relation Module which relates to a previous module I had started to utilise, but have now made redundant due to it's original author's Module depreciation, but in essense looking for an answer a generalistic approach to building such frameworks of this nature using common D7 modules (no custom coding at present), which I'm sure are very common.

Current overview found: http://www.lullabot.com/articles/photo-galleries-views-attach identities a similar issue, but I'm not too sure if this would be the correct/come best effective approach.

I am a newbie and any help is much appreciated. Anything I learn, I'll gladly pass it on here. Thanks in advance.


texts: Getting two errors when trying to click Extend and Config tabs

texts:
I'm getting the following errors:

  Drupal\Core\Extension\Exception\UnknownExtensionException: The profile does not exist or is not installed. in Drupal\Core\Extension\ExtensionList->getExtensionInfo() (line 346 of /app/drupal/core/lib/Drupal/Core/Extension/ExtensionList.php).
  Drupal\Core\Extension\Exception\UnknownExtensionException: The module does not exist or is not installed. in Drupal\Core\Extension\ExtensionList->getExtensionInfo() (line 346 of /app/drupal/core/lib/Drupal/Core/Extension/ExtensionList.php).

These errors are not telling me what module is missing.  I have not installed any modules. The only thing that I've done is update core from 8.7 to 8.8.1
The only thing that I've done is update from Drupal 8.7 to 8.8.1.  Is there anything I can do to find what module is causing the issue?


texts: How to load JS as the first item in head tag?

texts:
We have a custom module that has a JS library that we want to load in the <head> tag as the very first item even before all the normal Drupal JS files. All other libraries are loaded through mytheme.libraries.yml.

How can I load the library (mymodule/myscript) so that it loads as the first <script> tag in the <head>?

What we tried:

mymodule.module

function  mymodule_page_attachments(array &$page) {
  $attachments['#attached']['library'][] = 'mymodule/myscript';
}

mymodule.libraries.yml

myscript:
  version: 1.x
  header: true
  js:
    /path/to/file: { external: true, weight: -200 }

Current problem:

<head>
  <script>script1</script>
  <script>script2</script>
  <script>myscript is loaded here</script>
</head>

Goal:

<head>
  <script>myscript is loaded here</script>
  <script>script1</script>
  <script>script2</script>
</head>


texts: Right way to start with a Bootstrap subtheme?

texts:
I create my first Bootstrap subtheme (version 7.x-3.0) and I have 3 questions:

1) Theres is the file css/style.css which has more than 6400 lines, is this normal. I expected to it to be an empty page to start adding my custom css styles. Is this right?

2) I guess that I should not add anything in css/style.css and create my own files.E.g: blocks.css, prodcuct.css. Am I right?

3) How to create and declare a new .less file. E.g: blocks.less, products.less, etc. I know that the .css files must be declared in the .info file, but not sure about this kind of files.

I uploaded a capture where you can see the folder structure of the subtheme.


texts:
I'll start off saying I'm pretty new to Drupal.
I'm trying to customize the way a view displays. I want it to look like the Industry News section on this page: http://www.silverfishdevelopment.com/clients/maafs

However I'm confused as to what I want to actually edit. Do I want to create a custom views-view.tpl.php file? Or style output, or row style, etc?

And if I create a new tpl file, what are the variables I can use?

I was trying to follow this: http://www.wdtutorials.com/2011/06/29/drupal-7-how-create-custom-template-view#.VPXOIXXN9cY but couldn't get it to print out the $fields data.

Or am I approaching this all wrong?

If you know of a great tutorial too I'd appreciate that as well.
I'm a little overwhelmed with all of it. Thanks for any help you can give.


texts: I would like to activate Recurring Payments in Drupal. Is there a list of supported payment methods?


texts: How come I cannot fetch the name of the taxonomy term from term id?

texts:
We are doing the following query below to fetch all the taxonomy term values in the term_category vocabulary term. When we do the following query below, we get NULL value returned.

Content Type:

The Article content type has a field_category that is set to this new term_category taxonomy term.
Currently no Article nodes have any value populated for the field_category field as it is optional.

Taxonomy Term:

machine name = term_category
Label = Category
no fields other than title and description (which are out of the box)
has 15 values already added to the term (such as Cloud, IT, Security)

Goal:

Using the tid from the $term_categories result set, iterate through each one to get the name of the Taxonomy term.

How come I cannot get the name of the taxonomy term value from term id?

$db = \Drupal\Core\Database\Database::getConnection();
$term_categories = $db->query('select tid, vid from taxonomy_term_data where vid ='\'term_category\'');

foreach($term_categories as $category) {
  $category_term = (\Drupal\taxonomy\Entity\Term::load($category->tid));
  ksm($category_term->label()); // returns NULL.
  ksm($category_term->getName()); // returns NULL.

  // Goal.
  ksm($category_term->getName()); // Returns Cloud
}

Output of ksm($categor_term) -> content


texts: Modify the store for hundreds of products

texts:
I have a drupal 8 commerce website with 2 stores (store1 and store2). Most of the products belong to both stores but there are a few that only belong to either one.

Now, I need all the products (hundreds) to belong to a new store(store3) that i created on the website.

Obviously, I will not manually edit each product to assign it to the new store but what i was looking into is to write a SQL script (given that it's a one time thing) that will update the products in the DB. Soon after that i found out that it's more than the commerce_product__stores table that i would need to update, i would also have to update the commerce_promotion__stores and commerce_shipping_method__stores tables. and to make the things more complicated, some tables like the commerce_product__stores need its values updated where as with the other ones, i need to add the entries.

What better, Drupal way, ways of doing it are out there?
Another option that i found was talking about exporting all the products with the views data export module, modify the data and import it back in with the Feeds module but the author was complaining about some issues that were still not resolved in D8...

Any suggestions?


texts: Votes are not saved on refresh for Rate module

texts:
I am using rate module and created a rate widget for a content type with voting option as thumbs up/down.Set Interaction as 'Users vote if available, empty otherwise' and 'Users vote' for Which rating should be displayed when the user just voted.

I can vote the content but on node refresh its gone! and by default vote is shown as 50%

Votes are not getting saved. Is there any other setting I need to do? and Do I need to have BotScout.com API key to get the votes save?

I checked for earlier question but it was not helpful.


texts: I want to import a community database into drupal commons

texts:
I built a community webapp and now I want to migrate the database into drupal commons.

Is there a way to do that?

I have search the google and can not find information about it.


texts:
I need to create a view with user selected fields. My basic requirement is data export. My site contains around 1500 nodes and each node has around 25 fields. I have a view for data export with 5 fields.

My specific need is to create a control panel for selecting the fields i want – and in a following step I have to create a view with the selected fields.


texts: Content dependent on the IP of the viewing user

texts:
Is there any drupal module for implementing such behaviour?
I want to display content especially selected for the user, based on her localisation/IP.

Can you propose some solution?

For example, for a side bar I would like to have a set of filters:

in case of IP in mask xx.xx.xx.xx display side bar A
in case of IP in mask yy.yy.yy.yy display side bar B
in case of any other IP display default side bar


texts:
I am using drupal 6.22.

I have written a framework module that relies on submodules, when I install the submodule, I would like to update the administration menu to include some administration properties for the submodule.

This is the hook_menu implementation on the framework and it works no problem:

function svm_mail_menu() {

$items['admin/settings/svm-mail'] = array(
  'title' => 'SeeViewMedia Mailing Framework',
  'description' => 'Framework Settings for the SeeViewMedia Mailing application',
  'page callback' => 'mail_settings', //this needs to direct to a tabbed page that holds the framework options such as general settings and account add/edit/delete
  //This page should also be a "welcome" page for the module listing where everything is found
  //'access arguments' => array('Administer SeeViewMedia Framework Settings'),
  'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/svm-mail/add-account'] = array(
'title' => 'Add Mailing Account',
'page callback' => 'add_mail_account',
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
);
$items['admin/settings/svm-mail/view-accounts'] = array(
  'title' => 'View Mailing Accounts',
  'page callback' => 'view_mail_account',
  'access arguments' => array('Administer SeeViewMedia Framework Settings'),
  'type' => MENU_LOCAL_TASK,
);
return $items;
}

and this is the hook_menu_alter that I tried using, but it replaces my entire menu system

function ymlp_svm_mail_menu_alter(&$items) {
$items = svm_mail_menu();

$items['admin/settings/ymlp-svm-mail/update'] = array(
  'title' => 'Update YMLP Accounts Manually',
  'page callback' => 'ymlp_update',
  'access callback' => TRUE,
  'type' => MENU_LOCAL_TASK,
);
return $items;
}

How would I just add this little bit of menu to the original menu that I created without destroying everything else?


texts: The order of execution of the same hook implementation in two different modules

texts: I need to create two custom modules in Drupal 7. The two custom modules will implement the same hook. How can I guarantee the order of execution for the two custom module? I mean module1 will run first then module2 OR the reverse order?


texts: Subscribe to content type creation event

texts:
I'm using Drupal 8 (8.6.2). My main objective is to read fields of newly created content type (or changed, it doesn't matter) and create few helper data structures. To achieve this, I'm trying to somehow subscribe to an appropriate event. Unfortunately - no luck. Currently I have:

test_api.services.yml:

services:
    test_api_type.listener:
        class: '\Drupal\test_api\BundleEventsListener'
        tags:
            - { name: 'event_subscriber' }

And BundleEventsListener.php:

<?php

namespace \Drupal\test_api;

use \Drupal\Core\Entity\EntityBundleListener;
use \Drupal\Core\Entity\EntityTypeListener;
use \Drupal\Core\Entity\EntityTypeEvents;
use \Symfony\Component\EventDispatcher\EventSubscriberInterface;
use \Drupal\Core\Entity\EntityTypeEventSubscriberTrait;

class BundleEventsListener extends EntityTypeListener implements EventSubscriberInterface {
    use EntityTypeEventSubscriberTrait;
    public function __construct() {
            \Drupal::logger('test_api_mod')->notice('BUNDLE EVENT LISTENER CREATED');
    }
    public function onEntityTypeCreate($ent) {
            \Drupal::logger('test_api_mod')->notice('ON ENTITY TYPE CREATE');
    }
    public function onEntityTypeUpdate($lhs, $rhs) {
            \Drupal::logger('test_api_mod')->notice('ON ENTITY TYPE UPDATE');
    }
    public function onEntityTypeDelete($ent) {
            \Drupal::logger('test_api_mod')->notice('ON ENTITY TYPE DELETE');
    }
    public static function getSubscribedEvents() {
            return static::getEntityTypeEvents();
    }
}

Unfortunately this setup does not work - at all. This class isn't even instantiated - though I don't really know at what point it should happen. This seems to follow nearly line in line code from Drupal\views\EventSubscriber\ViewsEntitySchemaSubscriber class, but it simply does not work. I tried to implemented module described here and it simply works.

I am out of ideas at this point. Is this method supported? It should, this code is from Drupal's code. But maybe I'm subscribing to something different? But in this case - what is EntityType?

Also is there any documentation regarding split described here? It seems that I could listen to bundle creation and it would be fine, but there is no event type for this.

I'm completely lost, any help will be appreciated.


texts: Monitoring strategies for infrastructure

texts:
Lately, I have been facing some downtime on some of the Drupal sites I have deployed. I would want to approach the problem pro-actively, rather than reacting to those downtimes by restarting services or the server itself. I have read about monitoring tools like nagios, munin, cacti, etc to monitor the health of your server/infrastructure, but I haven't really tried one in production. I deal with Drupal almost 99% of the times, and I would like to find out suggestions for both server level monitoring, and Drupal (application code) level monitoring.

Basically, I would like to be notified when the server load is high, possibly being pointed to the culprit (or the victim), so that I could take informed decisions. I would also like to know what people use for Drupal level monitoring (such as emailing) when there is a PHP error/warning. (What happens when the email server itself is down?)


texts: Ask Drush to list which modules have database updates available

texts:
I specifically want Drush to list, of the modules that have available updates, which of those contain database updates.  Is this possible with Drush?

Edit for clarification: I know drush up will list all modules that have available updates, yes, but not all of those updates will have database updates that go along with them. I strictly want a list of updates that have associated database updates.


texts: Block Reference field not being filled with Value using the Conditional Fields

texts:
Hi I'm trying to add a specific block, based on taxonomy term that the user will pick from a field.

In more specific words, I have created a field linked to a Vocubulary and it displays like this to the user:
- Vocabulary
  - Value 1
  - Value 2
  - Value 3

And there is another field that is a Block Reference make me insert any Views Block that I have created.

What I want to achieve is that if the user selects Value 2 then the value for the Block Reference field will be filled with a specific view block, like: View: Value 2 Block : Teasers

I tried with different sintaxis but the Block Reference field is not being populated... any ideas why?
Thanks.


texts: A module to limit number of posts a user can make during a set period of time?

texts: I have a number of sites that allows users to post nodes and comments, however bots are getting a hold of these and having their way with my site. I recall seeing a module a while back (but cannot remember it's name) that allows admins to set a time limit between posts. Basically denying posts that made within minutes or seconds of eachother. Any ideas?


texts: Search highlighting for body field in Solr Seach API

texts:
I am using Search API for Solr and I see that it generates excerpts fine but it only works with Search API page when theme as search results is selected only.

I would like to get highlighting to work in my view.

I've created a view with exposed filter: Fulltext search

I've enabled highlighting option on the solr server level under advanced setting on the server (admin/config/search/search_api/server/xxxxx/edit), so I have enabled the following 3 options:

Return an excerpt for all results
Retrieve result data from Solr
Highlight retrieved data

I also enabled highlighting in the filter tab of the Search api index (admin/config/search/search_api/index/default_node_index/workflow)

When I add "Search Excerpt" as a field in my View, I don't get highlighting in the actual field, in my case it's the body field of the node,  but I can see highlighting in the excerpt field itself as you can see in the screen shot below.

Highlighting works just fine for the title field though, but not for the body or any other custom field type.

As you can see, it seems highlighting is working, but for some reason it doesn't show up in the body field. What am I doing wrong here?

I hope somebody there can help me as I have been struggling with this issue for a very long time.

Thanks!


texts: How to add a correlated subquery expression in hook_views_query_alter?

texts:
In hook_views_query_alter, how to add a condition which is a correlated subquery in which the value of the condition is an expression?

Given a view the produces this query:

SELECT node.nid, node.title, history.state
FROM node n
LEFT JOIN node_revision nr ON n.vid = nr.vid
INNER JOIN history h ON nr.vid = h.vid
WHERE (( (node.type IN ('blog')) ))

In order to show only the latest [state] for a given version (vid) of a node, we need to add this condition:

AND h.hid = (select max(hid) from history h2
where h2.nid = n.nid
and h2.vid = n.vid group by h.nid, h.vid)

So here's the statement we'd like to end up with after hook_views_query_alter:

SELECT node.nid, node.title, history.state
FROM node n
LEFT JOIN node_revision nr ON n.vid = nr.vid
INNER JOIN history h ON nr.vid = h.vid
WHERE (( (node.type IN ('blog')) ))
AND h.hid = (select max(hid) from history h2
where h2.nid = n.nid
and h2.vid = n.vid
group by h.nid, h.vid)

So we can see that our modified sql works, so here's our attempt (not working) to modify the statement on the fly:

function mymodule_views_query_alter($view, $query) {
  if ($view->name == 'my_view') {
  $expression = '(select max(hid) from
   workbench_moderation_node_history h
   where h.nid = node.nid
   and h.vid = node.vid
   group by h.nid, h.vid)';

  $condition = array();
  $condition['field'] = 'history.hid';
  $condition['value'][] = $expression;
$condition['operator'] = '=';
$query->where[1]['conditions'][] = $condition;
  }
}

This doesn't work (with or without the parenthesis) because the condition is an expression, not a value.  To validate that the syntax of adding a condition is correct, this will at least return results:

function mymodule_views_query_alter($view, $query) {
  if ($view->name == 'my_view') {
    $condition = array();
    $condition['field'] = 'history.hid';
    $condition['value'][] = '1';
    $condition['operator'] = '>';
    $query->where[1]['conditions'][] = $condition;
  }
}

How might we go about coding this constraint?


texts: File upload error "Files must be less than x MB" despite file being smaller than x

texts:
I have a file field called Video for a content type called Tutorial Video.
My settings are thus:

Allowed file extensions:
txt, mp4
Maximum upload size:
[empty]

The maximum upload section also has this text:

Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP's maximum post and file upload sizes (current limit 100 MB).

When I try to upload a 62MB MP4 video the Video field has (underneath the File Upload button) the following text:

Files must be less than 100 MB.
Allowed file types: txt mp4.

After I select the file and hit upload I get the following error message:

An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (100 MB) that this server supports.

I have requested my host upgrade my limits. They said they have set it to 250mb. I edited my php.ini and changed that to 500mb. I'm lost...


texts:
Over time, I have created some contributed module projects for D7. With D7 EOL not too distant in the future, I need to convert those to D8.

I've just started out doing this, and I've found the OO-style of D8 very different from the procedural style of D7.

For instance, I want to call the public function getTopics() that is part of the Advanced Help project. It can be found inside a file src/AdvancedHelpManager.php, and looks like this:

class AdvancedHelpManager extends DefaultPluginManager {
  …

  /**
   * Search the system for all available help topics.
   * @todo check visibility of the method.
   */
  public function getTopics() {
    $ini = $this->parseHelp();
    return $ini['topics'];
  }
  …
}

I want to call it from my module, in order to get hold of the list of topics I expect it to return.

So far, I've tried:

$foo = new AdvancedHelpManager();
$bar = $foo->getTopics();

but this returns the error "Error: Class 'AdvancedHelpManager' not found.

I guess I need to put some sort of "use"-statement on top of the file I try to use it, to make the class visible, but I am currently unable to figure out what that statement should be.


texts: How to Reload a Custom Drupal Theme (Without the Command Line)

texts:
How do I reliably reload a custom Drupal theme I am developing without access to the command line? Just clearing the caches before I perform the load only works sometimes.
FWIW, we are promised command-line access in the future (security issues yet to be ironed out) but not anytime soon.


texts:
Ok guys, I have made a product class with the same name as the machine name from 1 contentType, SO now all the items =(holidays) are now bookable/ready to buy.
I have one trip to thailand with a price of 1000 euro. This price depends on the hotel choice and the departure date. I thought to work with checkboxes for the hotels but I don't know what to do with the departure dates because every week has a different price and a different hotel.


texts: Display an image from an external database

texts:
I created new image database on localhost (other than Drupal original database) that has images in one column. Then I installed the Views Database Connector module; I could integrate it with Drupal to display the content of the new image database. I can easily see columns like name, email, phone number stored in this new image database as string of characters, which are all text columns. When it comes to display an image from the external database, I am stuck.
I tried saving images in two formats.

As URL linked to the path of the image file
As a BLOB

In the first case, I see the URL; in the second case, I see a string of characters.
How do I make the Views module understand that this field is an image it should display as image and not as text?


texts:
With Drupal 8 I'm having issues uploading images in a node.

I select an image in the upload dialog box and add it, yet when I go to view the page the image is not there? Directory permissions for image uploads are set to read/write.

When I inspect the source, I don't even see an image path.

My upload dialog box looks pretty crappy too.

What am I doing wrong?


texts: Suggestion tpl help for NiceMenu markup?

texts:
I'm using NiceMenus to display my taxonomy tree. Since I chose no parent menu, the module displays the root items as separate hoverable menu "tiles", which is OK. They are however
 items enclosed in one
. Due to styling/layout issues, what I want is that each of the tiles have individual parent
.

So instead of having:

root item 1

root item 2

root item 3

I want:

root item 1

root item 2

root item 3

and then I'll be able to easily absolutely position each
.

So the question is presumably a piece of cake for you guys: how to change the markup - probably using a suggestion technique... Should I override the block? How should I name the tpl file so to force my markup?

Thanks,
Artur


texts: Field prints twice, or not at all when added to template file

texts:
I have set my node field to 'Hidden' in the Manage Display page, and am printing the field in the corresponding tpl.php file, but the field only prints if I set the field format to 'Default' in Manage Display.

How can I hide the node field, and JUST print it in the template?

This is the code I'm using to print the field

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

so basically what's happening... is that if I set the format to 'Hidden' in Manage Display, the field doesn't display at all, and then if I set the format to 'Default', the field shows twice - once where I've printed it using the above code, and again in the content area.

What am I doing wrong?

Cache has also been cleared.


texts: Trouble with contextual links after node teaser refresh via ajax

texts:
Contextual links appears on page load, but upon node teaser refresh it disappears, I can see the dom is generated for even after the ajax refresh but the links are not appearing.

May be the problem is that after node teaser refresh the contextual links js needs to be processed.

Please guide me if anyone having idea about it.

Thanks.


texts:
I'm trying to use a jQuery plugin on a page to turn a table written in HTML into a bar graph. When I wrote the HTML and tested it from my computer, it works fine, but integrating it into the Drupal page doesn't seem to work.

I have the PHP filter turned on for the website.  My code for calling the file on the server and initializing it ready.

<?php
  drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', 'external');
  drupal_add_js('Biosci-jembrown.lsu.edu/usr/share/drupal7/aschoo2/TableBarChart.js', 'external');
?>
<link href="Biosci-jembrown.lsu.edu/usr/share/drupal7/aschoo2/TableBarChart.css" rel="stylesheet">
<?php
  drupal_add_js('jQuery(document).ready(function() {
    $('#machineHours').tableBarChart('#target', '', false); });', 'inline');
?>

When I save from the HTML text format of the page, I get a table; when I save from the PHP text format side, I don't get anything. How can I get the site to read the files and show the graph?

*******Edit:
I added the files through theme.php but it still doesn't work.  Perhaps the problem is the script that sends the names of containers as perimeters?  This is the theme.php where I added the code:

function bartik_process_page(&$variables) {
 //other code
drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', 'external');
drupal_add_js(drupal_get_path('theme', 'bartik') . '/template/TableBarChart.js');
$variables['scripts'] = drupal_get_js();
print $scripts;
drupal_add_js(drupal_get_path('theme', 'bartik') . '/template/RunJS.js');
$variables['scripts'] = drupal_get_js();
drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/TableBarChart.css');
print $scripts;


texts: Add a button that when clicked adds the user to the entity reference field

texts:
I have a Job content type (created only by a Client), with an Entity Reference field, "candidates".

Freelancers (user role) see a Views block of jobs created.

How do I add an "Express interest" button to each job so that the freelancer who clicks it gets referenced by the job?


texts: Block View Relationship between two content types

texts:
I have a Program content type which has a Paragraphs field which uses an Entity reference to a Course content type. Basically, when adding a program, I'm able to add a listing of what courses are available each semester. The semester is the paragraph field which includes a title (Ex. Semester 1) and then unlimited items to add the courses per semester. The courses are then shown on the program page by name and code and you're then able to click on the program name which takes you to the course page. This page has a description of the course and all the other info about it.

I have everything working how I need so far but what I'd like is to create a block view on each Course page that pretty much lists all the programs which this course is being taught in. I'm assuming I have to create some sort of Contextual Filter and perhaps a Relationships filter but everything I've tried has been a failure.

To sum this up: If a course is used by a program, display this program title on the course page in a block view.

Edit: Some images for reference

This is how the add courses paragraph looks on the Program content type

This is how the course page looks at the moment. I'd like an aside to the right showing the programs this course is taught in.

Edit 2: My relationships available

Here are the relationships that have the field courses:


texts: How to remove a prefix with hook_form_alter?

texts:
Looking at the source of a module, it is doing this:

$form['buttons']['back'] = array(
  '#prefix' => t('or'),
);

Now I want to remove that prefix; I tried the following code, but it doesn't make any difference.

function mymodule_form_formid_alter(&$form, &$form_state) {
  $form['buttons']['back']['#prefix'] = '';
}

I tested the following code, but it doesn't seems to work; the prefix is now 'testingor'.

function mymodule_form_formid_alter(&$form, &$form_state) {
  $form['buttons']['back']['#prefix'] = 'testing';
}

I tried the following code, but it doesn't make any difference.

function mymodule_form_formid_alter(&$form, &$form_state) {
  unset($form['buttons']['back']['#prefix']) ;
}

What am I doing wrong?

The form ID for the form I am trying to change is "commerce_checkout_form_checkout" which is used from the Drupal Commerce module.


texts:
I have inherited a complex site with multiple node type.

My current task is to prevent some nodes from loading based on some preset conditions. To accomplish that I used hook_node_view in the following function:

function accessibility_node_view($node, $view_mode, $langcode){
    drupal_set_message('Node View Responding');
}

That's just a simple test but I find that code responds on some nodes types but not on others.

Does anyone know a reason why that would be happening, please?


texts: How to programatically add block to Drupal 7 page tpl AND respect visibility rules?

texts:
I want to add a block programatically to a page.tpl.php file in my Drupal 7 theme BUT I want it to respect the block's visibility rules.

I'm open to defining new visibility rules in PHP too but it seems whenever I manually invoke a module via code without assigning the block in a region it does not adhere to the block's visibility rules.


texts:
I have installed the video filter module on my site. I added the following to my video source field.

[video:https://www.youtube.com/watch?v=686A5yPMWrs]

When I view the node, I get the following warning:

  Warning: Illegal string offset 'id' in Drupal\video_filter\Plugin\Filter\VideoFilter->process() (line 91 of modules/video_filter/src/Plugin/Filter/VideoFilter.php).

Is this something to pursue and fix? Is it safe to just disable the warnings when I push the site live?


texts:
Is there a module that allows the user to update multiple node fields in one page?

I found a method using Views (http://eureka.ykyuen.info/2012/12/13/drupal-7-update-multiple-nodes-at-once-in-a-views/), but I prefer to use module approach. Probably something that utilizes function node_mass_update (https://api.drupal.org/api/drupal/modules!node!node.admin.inc/function/node_mass_update/7)


texts: I have a content type "Review" and there there is dropdown for brands, I want to order dropdown list by alphabetical order. is there any way to reordering drupal node reference dropdown?


texts: Multiple fields search with finder and results sorting

texts:
I configured a view, listing hundreds of elements, like this:
Name, Type, Result, Other

Now, I need to search it, with multiple forms, simultaneously, in this way:
Search element n.1: [INPUT]
Search element n.2: [INPUT]
Search element n.3: [INPUT]
Search element n.4: [INPUT]

I tried to implement it using "finder" module and autocomplete fields. Everything works fine, but results are sorted in the same order of the view, and there is no way to change this behavior...
I need instead to show results respecting the order of the search. So, if I search
foo, bar, foobar, I want to show first results in this order (foo, bar, foobar), not in alphabetical order like the original view.
I think I have to modify the view with a views hook, but I'm not able to fix my problem yet...
How can I sort the results of this search page?


texts: How do I make my site with pre-loaded content and pre-loaded config available to others without creating a distribution?

texts:
I want to be able to provide a simple way for users to install a Drupal website that contains a certain set of content, contributed modules and custom content types. I also want to keep the process of developing this scenario as simple as possible for the developer.

I know that the standard way to do this would be to create a Distribution such as those that are listed at https://www.drupal.org/project/project_distribution. Another example is the Umami content available in a standard Drupal distribution. However, building a distribution seems to be quite a bit of work and should require a commitment to maintain that distribution if it is listed on the Drupal website. So, my question is whether there is a simpler way to allow users to install a website with some given content without my having to make the effort of building a distribution, since whatever I build will not be listed on the Drupal website.

The thought that there may be an easier way was prompted by my experience with some theme vendors. With some theme vendors, the process of installation involves only creating a database from an included SQL script and then starting the installation wizard and only having to input the database credentials. No other answers need to be answered in the installation wizard. It is almost as easy for the user as installing a distribution, and I am wondering if it may be easier for me as a developer to implement.

When I examine some of these theme installations that use this approach (e.g., News+ lite at https://www.drupal.org/project/newsplus_lite) there is no code in the docroot/profile sub-directory, so this approach cannot be using a standard install profile or distribution because that is where extra content or code would be stored for an install profile or distribution. From my investigations so far about creating Distributions or Installation Profiles, I have not yet read how such an approach would work or be implemented. So, I am asking if anyone knows how such an approach (as utilized in the News+ Lite and other similar installations) works and how I might duplicate it.


texts: How can I change the year range displayed by a FAPI date field?

texts:
I have created a FAPI form with an element of #type => date and it works as expected.

$form['date'] = array(
  '#type' => 'date',
  '#title' => t('Event date:'),
);

However, the options displayed in the year field range from 1900 - 2050. I would like to be able to limit this to a much smaller range starting with the current year. What would be the best way to accomplish this?


texts: Is it possible to have language specific content?

texts:
I am working on a Drupal 7 site that is currently in English only. We are now looking at adding additional language support and so far I've got the hang of content translation using i18n.

We currently have a news section composed of articles for each story. Is it possible to write language-specific articles? E.g. if there is a French-only news story, it won't appear on the English language site.


texts: Why are no tests shown on testing overview?

texts:
I want to run DrupalWebTestCases on my custom Drupal 7 module.

Following the Tutorial at https://drupal.org/simpletest-tutorial-drupal7 i'm stuck at running the tests:
also after cache deletion no other Tests than for SimpleTest are found on the /admin/config/development/testing-page.

I'm using the contributed SimpleTest module, added the testing_api = 2.x setting to my modules .info.

mymodule/mymodule.info:

name = Mymodule Reports
core = 7.x
php = 5.3
files[] = tests/*.test
testing_api = 2.x

mymodule/tests/mymodule.test:

/**
 * @file
 * Mymodule reports module tests.
 */

class MymoduleReportsTestCase extends DrupalWebTestCase {

  public static function getInfo() {
    return array(
      'name' => 'MymoduleReports',
      'description' => 'Ensure that the locking of nodes functions properly.',
      'group' => 'Mymodule',
    );
  }

}

What i'm doing wrong?


texts:
I am working with drupal 7 and I need to attach a gallery to the content type. I looked at the current solutions where I can create a Image content type and  create node references. I am looking for something where any user would be able to contribute images, multi-upload images at the same time, if possible can also add images from URL.

Also is it possible to do something where the user can just click on a "Add images" link and the user would be presented with a image upload screen ?


texts: upload picture and make it my css background-image

texts:
I want to upload picture and make it my CSS background-image in Drupal? Is it possible?

Please reply if you know how thank you!


texts: fastest between hook_js vs hook_menu to get JSON via REST

texts:
I'm trying to figure out if in my case it makes sense to use the High-performance JavaScript callback handler module.
Between js/MODULE/example.json (hook_js()) and example.json (hook_menu()), the difference of time is not huge, but I think hook_js() is faster.

In a case I'm not using any Drupal function, variable or session, and I'm only calling another server with REST. Can I bypass all the bootstrap functions, or do I have to use the first layer (DRUPAL_BOOTSTRAP_CONFIGURATION)?

What would be the faster solution?

function MODULE_js(){
    return array(
      // Example URL is /js/MODULE/example.json
      'example.json' => array(
        'callback' => 'my_json',
        'includes' => array('unicode', 'locale', 'language'),
        'dependencies' => array(),
        'bootstrap' => DRUPAL_BOOTSTRAP_CONFIGURATION,
        'access callback' => 'access_callback',
        'access arguments' => array(),
        'page arguments' => array(),
        'skip_hook_init' => TRUE,
        'delivery callback' => 'drupal_json_output',
      ),
    );
}
function access_callback (){
    return true;
}

function MODULE_menu()
    $items['example.json'] = array(
        'type' => MENU_CALLBACK,
        'page callback' => 'my_json',
        'page arguments' => array(),
        'access callback' => true,
        'delivery callback' => 'drupal_json_output',
    );
return $items;
}

function my_json(){
    //call with curl/rest and return a json
    return 'json';
}


texts: I get a syntax error when I try to execute a query

texts:
Each time I run the following code, I get an error.

$result = db_query(“SELECT nid FROM 'msg'”);
foreach ($result as $record) {
  // Do something with each $record
}

The error is the following one:

  Parse error: syntax error, unexpected T_STRING

How do I fix the error?


texts:
I have a problem that I'm unable to solve. I created content type named test player to display files with Able Player, that is an accessible audio player for blind users. So, I installed requested modules, and it works fine.

Now, when the page gets displayed, there is a link to file, that shows a page with file name and other info. This link is going to be read before the audio player tag from screen reading software. so, if the user click this link, it reaches a page that doesn't have the audio player, but only the name of the file.

I want to display only the audio player without the link to this file. Is there a way? I tried it already with another audio player, but the link appears again.


texts: Form API: Show/Hide/Select option based on a previous option

texts:
Possible Duplicate:
  Easiest method for conditional fields in a form

Essentially I have 2 select fields on a form:

EDIT: I should mention, this is an entirely custom form built with Form API, I'm not modifying a core/contrib form.

Type

Global
Regional

City

Any
London
New York
Paris
LA

If Type:Global is selected, then the City field is hidden and City:Any is selected.

If Type:Regional is selected, then City is revealed, City:London selected and City:Any hidden.

Is there a Drupal or Form API compliant method to achieve this or is it simply a case of loading a JS file with drupal_add_js and writing entirely custom JS?

If it's simply custom JS/JQuery no need to write it out for me, I can handle that, but I would like to try and stick to the standard and best practices if there are any for my problem.

Thanks!


texts: How to allow filtering by only date parts selected by user and make not selected work as "Any"?

texts:
I am using the Date module and I am creating a view to display news content; I made a exposed filter to search news content by year, month, and day. When I search, I need to select all the date fields.

Is it possible to search entering values for just one of those fields?

How can I remove these validation in search time?

How can I remove this validation from exposed search filters ?
I want to search content
condition should like this:-
Year "OR" Month "OR" Day

condition should not like this:-
Year "AND" Month "AND" Day


texts: Views: show only one node per select box value

texts:
I created a Block showing the latest 3 articles ("pets") as teaser (not using fields). The content type has a field type which can be dog, cat or other.

Now i want to show only one of each type: one dog, one cat and one other. I don't have any idea how i can do that... I have some filter criteria (content-type=pet, available=yes, public=yes) and sort criteria (content:date_arrived desc) and limited to 3 items.

Thanks for any help / hint!

I'm using drupal 7 and the newest views-module.


texts: How to preserve Drupal file permissions after compressing and moving as tarball?

texts:
I seem to be frequently encountering a situation when I compress files of a Drupal site as a tarball from a production server to the public_html folder of my  local machine.

The permissions seem to get messed up and I usually end up with a filesystem not readable error and  deleting a few files in the sites/default/files directory during the process of changing the permissions.

How can I preserve these permissions when the folder is compressed and copied to a new folder or is it an issue with the permissions of the destination folder?


texts: How do I print field collection's fields horizontally?

texts: I have a custom node module in which there is one field collection which includes 5 other fields, and I implement hook_theme to define a custom template to theme this specific node form. In the custom template file I add "print drupal_render_children($form);" and it prints the field collection's field. How do I print the individual fields horizontally??


texts: Adding Local Tasks gives Page Not Found 404 error to all tabs excluding default tab using local tasks?

texts:
Under custom_changes.links.task.yml

custom_changes.menu_example.tasks:
  route_name: custom_changes.menu_example.tabs
  title: Default primary tab
  base_route: custom_changes.menu_example.tabs
custom_changes.menu_example.task_view:
  route_name: custom_changes.menu_example.tabs_view
  title: Second
  base_route: custom_changes.menu_example.tabs
  weight: 2
custom_changes.menu_example.task_edit:
  route_name: custom_changes.menu_example.tabs_edit
  title: Third
  base_route: custom_changes.menu_example.tabs
  weight: 3
custom_changes.menu_example.task_delete:
  route_name: custom_changes.menu_example.tabs_delete
  title: Fourth
  base_route: custom_changes.menu_example.tabs
  weight: 4

Under StaticContent.php ( src\Controller\StaticContent.php )

<?php

namespace Drupal\custom_changes\Controller;

use \Drupal\Core\Controller\ControllerBase;
use \Drupal\node\Entity\Node;

Class StaticContent extends ControllerBase  {
  public function static_callback() {
    $build = [
      '#markup' => $this->t('Hello World!'),
    ];
    return $build;
  }
  public function tabs() {
    $build = [
      '#markup' => $this->t('Hello World!'),
    ];
    return $build;
  }
  public function tabs_dynamic_view($id) {
    $build = [
      '#markup' => $this->t('Hello World! VIEW'. $id),
    ];
    return $build;
  }
  public function tabs_dynamic_edit($id) {
    $build = [
      '#markup' => $this->t('Hello World! EDIT'. $id),
    ];
    return $build;
  }
  public function tabs_dynamic_delete($id) {
    $build = [
      '#markup' => $this->t('Hello World! DELETE'. $id),
    ];
    return $build;
  }

Under custom_changes.routing.yml

custom_changes.menu_example.tabs:
  path: '/tabs'
  defaults:
    _title: 'Tabs'
    _controller: '\Drupal\custom_changes\Controller\StaticContent::tabs'
  requirements:
    _permission: 'Access Tab Content'
custom_changes.menu_example.tabs_view:
  path: '/tabs/{id}/view'
  defaults:
    _title: 'Tabs View'
    _controller: '\Drupal\custom_changes\Controller\StaticContent::tabs_dynamic_view'
    id: 2
  requirements:
    _permission: 'Access Tab Content'
custom_changes.menu_example.tabs_edit:
  path: '/tabs/{id}/edit'
  defaults:
    _title: 'Tabs Edit'
    _controller: '\Drupal\custom_changes\Controller\StaticContent::tabs_dynamic_edit'
    id: 2
  requirements:
    _permission: 'Access Tab Content'
custom_changes.menu_example.tabs_delete:
  path: '/tabs/{id}/delete'
  defaults:
    _title: 'Tabs Delete'
    _controller: '\Drupal\custom_changes\Controller\StaticContent::tabs_dynamic_delete'
    id: 2
  requirements:
    _permission: 'Access Tab Content'

I get Page Not Found 404 for Tabs View, Edit and Delete Tabs whereas it
shows the default tab '/tabs'.
What is not correct in the code above?

It works when I remove {id} slug from routes.Does this support only static contents?


texts: Request for new password when user login for the first time

texts:
I am using darland theme in drupal7 site and I want user to reset their password for the fist time when they login with temporary login credentials given by admin,i,e created user when he login for the first time he should able to see the reset password form and later he can use his account as required,!!how to resolve this issue??can anyone know?

And below screen shot which i have added is my login screen and the code showing up in the right page is cos i have added the code in page.tpl.php to solve above problem explained so now it looks like, however if i take off the code from page.tpl.php it will be removed.


texts: Recurring events - retrieving/displaying the dates for the current "instance" of the event

texts:
I have an events page on my (D7) site, and the admin can set up recurring events.

When creating a list of the events, I see the recurring events come through in the right place intermingled with the non-recurring events.  However, their dates don't show up right:

My "normal" date fields only ever show the date of the first event.  There's an answer to this issue here, but that requires table layout.  I'd prefer not to have to use table layout.  Any idea how I could do this without it?

Secondly, I'm using a pre-process field (called big_date) to create a second date field but with a different display to the first, so I can display the same date in different formats simultaneously.  How could my code here know which of the many dates in $vars['node']->field_date_and_time[LANGUAGE_NONE] is the one relating to the "current" instance of the event?