texts: Media theme missing from the file system?

texts:
Not really sure about this error, I wasn't aware there was a media theme but could anyone help me understand this please?

  User warning: The following theme is missing from the file system: media in drupal_get_filename() (line 268 of core/includes/bootstrap.inc).
  drupal_get_filename('theme', 'media') (Line: 291)
  drupal_get_path('theme', 'media') (Line: 394)
  Drupal\Core\Asset\LibraryDiscoveryParser->drupalGetPath('theme', 'media') (Line: 85)
  Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension('media') (Line: 87)
  Drupal\Core\Asset\LibraryDiscoveryCollector->getLibraryDefinitions('media') (Line: 66)
  Drupal\Core\Asset\LibraryDiscoveryCollector->resolveCacheMiss('media') (Line: 149)
  Drupal\Core\Cache\CacheCollector->get('media') (Line: 44)
  Drupal\Core\Asset\LibraryDiscovery->getLibrariesByExtension('media') (Line: 58)
  Drupal\Core\Asset\LibraryDiscovery->getLibraryByName('media', 'form') (Line: 54)
  Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies(Array, Array) (Line: 56)
  Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies(Array) (Line: 31)
  Drupal\Core\Asset\LibraryDependencyResolver->getLibrariesWithDependencies(Array) (Line: 104)
  Drupal\Core\Asset\AssetResolver->getLibrariesToLoad(Object) (Line: 116)
  Drupal\Core\Asset\AssetResolver->getCssAssets(Object, ) (Line: 291)
  Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries(Object, Array) (Line: 161)
  Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object) (Line: 45)
  Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object, 'kernel.response', Object)
  call_user_func(Array, Object, 'kernel.response', Object) (Line: 111)
  Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object) (Line: 191)
  Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 173)
  Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
  Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
  Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
  Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
  Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
  Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
  Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
  Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
  Drupal\Core\DrupalKernel->handle(Object) (Line: 19)


texts: Views Infinite Scroll Set default page with position

texts:
There is a view page with views_infinite_scroll paging.
This page is being used for list products.

Everything is working as I needed, but the problem is:

Suppose I'm on 5th page(Note: with scroll pagination) and I click on product to go to it's detail page, the detail page have a link to return back to the product listing page. So, when user clicks on "Back to previous Page" link on product detail page, it should display the 5th page with exact page view position.

Please help how should we achieve this?

Thanks In Advance


texts:
How to add tags to View-created RSS feed?

I have added some tags to each of my articles, but the RSS feed generated by Views does not show the tags.


texts: What's the difference between using Drupal's jQuery library and adding it in html.tpl.php?

texts:
I'm recoding one site (D7) where I stumbled upon statically added jquery (using a script tag inside html.tpl.php that pulls jquery library from google CDN). I installed "jQuery CDN" module that does the same and expected that when I loose statically added script tag everything would stay the same, but the menu and slider don't work (menu is implemented using some internal jsddmenu.js file, also slider using slides.jquery.js). What's the difference between those two implementations, when both of them add:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>

to the html code?


texts: How to use contextual filters to a View for use as a sort criteria?

texts:
I want a View with a default sort criteria that can be overridden by a contextual filter.  For example, the URL might end like this: ?sort=popular.  popular would be associated with one field and recent, the default, would be associated with another field.
This is on Drupal 7 and Views 3.


texts: Do not send registration mail to fake users, who haven't specified their gender in registration form

texts:
Since several years I run a Drupal 7 web site - as a frontend to a multi-player card game.

I have the following SPAM protection at my web site: the new users should specify their gender at the registration (it should be "Male" or "Female", but not the default "Robot") and then they have to play the card game:

Every night I run a cronjob, which deletes users who have wrong gender or who have registered 10 days ago and still haven't played:

delete from drupal_users
where uid <> 0 and
to_timestamp(created) < (now() - interval '10 day') and
uid not in (select distinct id from pref_money); /* haven't played the game */

This does work well, BUT recently the amount of registering fake users has increased to hundreds per hour and my site keeps sending lots of registering mails (which bounce then to my poor mailbox) every minute.

So my question is: how NOT to send the registration mail to users who have their gender set to "Robot"?

Here is what I have found sofar:

1) The gender (an additional field at my reg. form) can be found the following way:

        $result = db_query('select field_gender_value from {field_data_field_gender} where entity_id=:id', array(':id' => array($viewer_id)));
        $gender = $result->fetchField();
        if ('Robot' == $gender) {
           ....
        }

2) And I probably should provide a hook_mail_alter in my custom module:

function MY_CUSTOM_MODULE_mail_alter(&$message) {
  # XXX how to find gender here?
  if ('Robot' == $gender) {
      # XXX how to abort mailing for registration only?
      $message['send'] = FALSE;
      return;
  }
}

But in 2) I don't know 2 things - how to find the gender value there and how to cancel the registration mails only?

Any suggestions please?

Please do not suggest the Mollom module or any standard Drupal anti-spam measures, because my question is very specific.


texts:
I installed Pathauto, Tokens and Entity API module in Drupal 8 and I have been unable to create a pattern that would allow parent taxonomies and then the final node for content type pages. In Drupal 7 the entity API module would add the extra tokens I need but it does not seem to work for Drupal 8.

For Drupal 8 the token [term:parents:join-path] works but it is only usable for taxonomy type pages and not content type pages.

If anybody can help me,I would greatly appreciate it.


texts:
Im at a bit of a loss here, this error started happening when saving a new node, or updating an existing node.

It says The website encountered an unexpected error. Please try again later..

The error on the screen is...

  Notice: Undefined index: fid in file_field_update() (line 276 of
  C:\wamp\www\thelhp\modules\file\file.field.inc).

  Notice: Undefined index: fid in file_field_update() (line 302 of
  C:\wamp\www\thelhp\modules\file\file.field.inc).

  Notice: Undefined property: stdClass::$fid in file_usage_add() (line
  689 of C:\wamp\www\thelhp\includes\file.inc).

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Le
  champ 'fid' ne peut être vide (null): INSERT INTO {file_usage} (fid,
  module, type, id, count) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4); Array (
  [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => file
  [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 196
  [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 696 of
  C:\wamp\www\thelhp.co.uk\includes\file.inc).

I am now not able to create nodes, or update existing ones.

HOWEVER, after further testing, I have found that if I upload an image to the optional image field, nodes save and update just fine. When no image is uploaded, the errors show up. help! :-(


texts: How to restrict ckeditor to display full html alone?

texts:
I am using ck editor and want to hide the filtered html and plain text.

And user should use only the full html format. They should not get the option to select filtered html and plain text.

Anyone guide me how to do this in ck editor?


texts: Required field set via hook_form_alter not fully working in Commerce Checkout form

texts:
I created a hook function to make a field required and visible. The targeted form is the Checkout Billing Form at: example.com/en/checkout/35

I have to mention that the site is build with the Commerce Kickstart distribution.

        <?php
    function MyModule_form_alter(&$form, &$form_state, $form_id) {
            if ($form_id == 'commerce_checkout_form_checkout') {
                    $form['customer_profile_billing']['field_cif_nif_id']['#states'] = array(
                      // This #states rule says that the "field_cif_nif_id" fieldset should only
                      // be VISIBLE and REQUIRED if the "field_dispongo_de_" form element is set to "CIF/NIF/ID".
                              'visible' => array(
                                    '#edit-customer-profile-billing-field-dispongo-de-und' => array('value' => t('CIF/NIF/ID')),
                            ),'required' => array(
                                    '#edit-customer-profile-billing-field-dispongo-de-und' => array('value' => t('CIF/NIF/ID')),
                            ),
                    );

                   $form_state['rebuild'] = TRUE; //THIS LINE IS NOT WORKING
      }
    }
    ?>

The function seems to work fine since the fied is marked with the red asterisk *, but it is not really working since the form is sent and saved even if the required field is empty.

I think the problem is not in the function but in its relation with the Commerce Checkout form provided by Drupal Commerce or Commerce Kickstart.


texts: Taxonomy term description gets emptied on term save

texts:
I have a vocabulary with a description field that's of the "Long text and summary" type.
Every time I edit and save a taxonomy term from that vocabulary, the description gets emptied.

Did any of you encounter this bug?
Is there any way of fixing it?


texts: How to include desktop css file only on desktop & mobile css file only on mobile?

texts:
I have two different css files in my theme, one for Desktop and other for Mobile version. I want to render Desktop css file only for desktop mode and Mobile css file only for mobile mode.
Do I need to make any modification in .info of my Theme?


texts: How to add additional tabs to user profiles

texts:
I'm trying to find a way to add another tab to the tabbed menu under each user's username on the user/* page.

I want to have View, Edit, and an additional link. I'm not sure where I need to be looking in the code to edit this menu and I can't find any documentation thus far. Any help would be great.

Thanks


texts: Drupal 301 redirects for matching paths without .htaccess

texts:
I am using a Drupal site on top of nginx, and would like to be able to redirect a set of pages from an old style url, to a new one, using 301s. The content has already been migrated over to the new urls, but there may be links elsewhere with the old style. How can I achieve 301 redirects for matching paths, to redirect using part of the information from the old url to inject into the new one (namely [timestamp]).

From:

example.org/article/[timestamp]

To:

example.org/article/doi/static-[timestamp]

I know how I would do this with .htaccess, but is there a way to do this in Drupal itself, or a module to achieve this?

Having looked at the docs, I think that

drupal_goto($path = '', array $options = array(), $http_response_code = 301)

May be the best way to go, with a corresponding (pseudocode):

if path == oldpath,
    drupal_goto(etc.)


texts: User permissions on a costum content type

texts: I've created a custom content type with fields (it's like a form), I've already added permission to logged users to use my form(content type) but I want to hide some checkboxes on this form only when user is not admin. so how to hide (remove) a part of fields of a content type ?


texts:
I have a weird question. Let's say we have this form:

$form['field1'] = array(
  '#type' => 'textfield',
  '#title'  => 'First field'
);
$form['container'] = array(
  '#type' => 'container'
);
$form['container']['field2'] = array(
  '#type' => 'textfield',
  '#title' => 'Second field'
);

Now if you set an error for field2, you do it like this:

form_set_error('field2', 'error message');

and not like

form_set_error('container][field2', 'error message');

I wonder how does drupal does recognize the right form element to add the error class. I wanna do something like that, to add a suffix for every field who did not passed validation.

I tried getting the error field with form_get_errors() but it returns field2 as a field with an error. It's obvious that $form['field2'] does not exists add I can't add a suffix to it.

Any help is greatly appreciated. Or at least a hint to the right direction. Thanks :)


texts: I want to override theme node.tpl.php file with node--[content-type].tpl.php in my custom module

texts:
I am making a new custom module. and i have 1 content type called city management(city-management).
I want to override theme node.tpl.php file with node--city-management.tpl.php in my custom module.

Is it possible?


texts: Child menu items not displayed in drupal

texts:
I've a sub-menu like this:

I'm trying to build a custom theme, I just copied which contains following code:

<?php if ($main_menu || $secondary_menu): ?>

    <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
    <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>

<?php endif; ?>

This is how its being displayed: Note that not even the HTML for child menu items are generated.

Yes, I've Show as expanded option checked for "Publications".

PS:
Why does drupal make even such simple things difficult. No wonder, its losing ground to wordpress.


texts:
Does Drupal support chunked AJAX responses in either direction?

I have not been able to find materials on this so far and am curious:

Is Drupal AJAX capable of working with chunked AJAX responses (Does it have the functionality of waiting until all chunks are received and display them as soon as possible)
Does Drupal have functionality to send Chunked responses to an AJAX request (Send data as soon as it's ready, so it can be displayed to the client)

What I mean by chunked AJAX is basically what multiple service booking sites do (example: airline tickets) They do multiple requests to different service providers and airlines, and results are displayed as soon as they're available and populated with more as they are sent.


texts:
We're relying on the Media module heavily for embedded video throughout our site.  When Media is used for a field, it is working beautifully for us.

We ran into problems, however, embedding Media rich text fields. We're using CKEditor, which strips Media tags when using filtered HTML. For security purposes, we want all non-admin users to continue using filtered HTML.  There were other complications, too: The UI was a little strange since you had to add the (non Media) image button to allow users to align images.  So they'd have two image-y buttons, one to upload and one to style. Finally we decided we could keep rich text pared down to text without images.

However we've also been using Media to upload files (documents/docx/pdf).  And we definitely want users to be able to link to files in the editor.  Should we use CK Finder?  Or is there a way we can expose the view at admin/content/file to non admin users so they could have an inventory of files and copy urls? Or rebuild a similar view, as described here?

I feel like I must be overlooking something obvious, as this seems like a very basic CMS feature... Have I managed to obscure functionality with my permissions and plugins?
Thanks!


texts: How can I hide one commerce specific shipping option without deleting?

texts:
I am trying to hide a couple of Commerce shipping options we no longer use.

I can't figure out the proper syntax for addressing the individual form radio options.

Here is what I have so far:

function MYMODULE_form_commerce_checkout_form_shipping_alter(&$form, &$form_state, $form_id) {
    $form['commerce_shipping']['shipping_service']['#options']['express_shipping']['#access'] = FALSE;
}

...this throws an error ' Illegal string offset #access'. Am I addressing the wrong member of the array? I've used this code before successfully for text and select fields, but never a radio.

Thanks so much!


texts:
Is there a way to have date/time fields with the date_popup type, but have the time field be something optional for the user to fill in?

I have the UI with both a Date and Time field with the following code:

$form['mygsb_settings']["publish_on_start_date"] = array(
    '#type' => 'date_popup',
    '#title' => "Publish Start Date",
);

But when a user doesn't enter the start time, I get back the following validation error from drupal.

The value input for field Publish Start Date is invalid:
The value 2012-03-14 does not match the expected format.

Is there any way to avoid this validation error? Basically, I want to make the time field optional.

Greg


texts: Entity reference field autocomplete in paragraph bundle fails

texts:
In drupal 7 I have a content type with an included paragraph bundle which is an autocomplete entity reference field. The field has an entity selection mode of Views: filter by entity reference view, linked to an entity reference view.
But, the autocomplete only works correctly once the draft is saved and you go back in and edit the field entry in the draft.  On first try, it always incorrectly displays a bulleted list, and the links on that list do not populate the field correctly.
I am at a loss. I can't locate any patch for this scenario. Any ideas welcome. Thank you.


texts: Remove the title field for a custom content type

texts: Is there a way to replace the "title" field from a custom content type with an auto-increment ID? Since the Automatic Nodetitles module does not have a Drupal 8 version, is there a way to do it using hooks?


texts:
I was doing some zip processing and came through the code which update_manager_archive_extract() uses. This is the code:-

$path_to_zip = '/some-local-path/testfile.zip';

$archiver = archiver_get_archiver($path_to_zip);

$files = $archiver->listContents();

$extract_location = '/some-extract-location/';

 if (file_exists($extract_location)) {
      file_unmanaged_delete_recursive($extract_location);
 }

$archiver->extract($extract_location);

I am getting "FALSE" result from archiver_get_archiver(). The $archiver variable is FALSE.


texts: Redirect 'user' and 'user/uid' to 'users/name'

texts:
I have been trying to redirect the default user url of '/user' to the url alias of '/users/username'.

If i go to '/user/uid' it redirects properly but if i type in '/user' the url doesn't redirect.

Using hook_preprocess_user_profile() I can print arg(0) and arg(1) with drupal_set_message() and it display that arg(1) exists as the uid on '/user'.

I have tried

function mymodule_preprocess_user_profile(&$vars) {
  global $user;
  //print_r($vars);
  if (arg(0) == 'user' && arg(1) == $user->uid){
    //drupal_set_message('0'.arg(0).'1'.arg(1));
    drupal_goto("users/$user->name");
  }
}

but this end up in an endless redirect. Is it possible to even accomplish this?


texts: How can I check if a select field has been used with states?

texts:
I have a form where I'd like to hide a fieldset until the user has used a select (which option doesn't matter).

So far I've the following code:

$form['location'] = array(
  '#type' => 'select',
  '#options' => $locations,
  '#required' => true,
);

$form['uploads'] = array(
  '#type' => 'fieldset',
  '#title' => 'Foobar',
  '#states' => array(
    'visible' => array(
      'select[name="location"]' => array('empty' => false)
    )
  )
);

Apparently empty, checked, filled don't do the trick. If I check for one specific value with the following code works.

'#states' => array(
  'visible' => array(
    'select[name="location"]' => array('value' => 'foo')
  )
)

But what would be the solution for the check if any value has been selected?


texts:
It seems that most view field filters allow the setting 'any', or leaving it empty, to basically disable the filter. I don't see a way in a date field to do the same.
I have a date with selectboxes for year, month, and day; exposing the operator gives a number of options, including 'is empty' or 'is not empty' but I can't choose 'any'.

How do I set an exposed date filter to allow any value, empty or not empty?


texts: Question about Managing JavaScript in Drupal 7

texts:
If you go to  https://www.drupal.org/node/756722#behaviors    at Behaviors section you will see:

  (function ($) {
     Drupal.behaviors.exampleModule = {
     attach: function (context, settings) {
     $('.example', context).click(function () {
     $(this).next('ul').toggle('show');
  });
 }

};

})(jQuery);

I think 'example' should be the name of a class like:

<?php echo click here?> <?p>

so when clicking on "Click here", the toggle will work. Am I right? And also what is 'ul' in $(this).next('ul').toggle('show');?

So if I have :

 for($b=1;$b<$number;$b++)
   {  ?>

<?php echo "Commentsfor Paragraph $b:" ."
" . "
" ; ?>

    <?php
      print render($p[$b]);
      ?>

 <?php

      }

and what I want to hide or show is the in , then can I write:

or can I mention the class or id of div  in $(this).next('div').toggle('show'); , so that the data in that part will hide or show? I hope I am clear.


texts: Is it possible to make summary mandatory?

texts: For a given content type is it possible to make creating a summary mandatory?


texts: how to get all the values in an edit form

texts:
I want to see all the values in my edit form, I tried
dsm($form_state->getValues())  but i dont get anything.
if I do dsm($form_state) I get a huge amoung of things too much to look through.

what is the correct syntax to get just values in my form in the edit page.


texts: Drupal 8: javascript not loading in theme

texts:
I would like to add a little javascript to my bootstrap child-theme, but is not loading.

These are the configuration files:

child.info.yml :

 core: 8.x
type: theme
base theme: bootstrap

name: 'child'
description: 'Uses the jsDelivr CDN for all CSS and JavaScript. No source files or compiling is necessary and is recommended for simple sites or beginners.'
package: 'Bootstrap'

regions:
  navigation: 'Navigation'
  navigation_collapsible: 'Navigation (Collapsible)'
  header: 'Top Bar'
  highlighted: 'Highlighted'
  help: 'Help'
  content: 'Content'
  sidebar_first: 'Primary'
  sidebar_second: 'Secondary'
  footer: 'Footer'
  page_top: 'Page top'
  page_bottom: 'Page bottom'

libraries:
  - 'child/global-styling'

child.libraries.yml:

global-styling:
  css:
    theme:
      css/style.css: {}
      css/masonry.css: {}
      css/basic-page.css: {}

  js:
  js/main.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

main.js

$(document).ready(function($) {
    $(function() {
        $(window).scroll(function() {
            var scroll = $(window).scrollTop();

            if (scroll >= 300) {
                $("#navbar").addClass('smaller');
            } else {
                $("#navbar").removeClass("smaller");
            }
        });
    });
})(jQuery);


texts: How can I change the delete message "This action cannot be undone." in a specific content type?

texts:
I have a version drupal 6 and I need to change the next message that is shown  when I am going to delete a content:

"This action cannot be undone."

I need to change this message only for some content types, not in all.

Thanks for your help.


texts: How to decide between Entity API exportables and CTools exportables?

texts:
I'm planning to add support for import/export/clone facilities in the D7 version of the Goals module, similar to the import/export/clone facilities in (e.g) the Rules. More specifically to also provide support for importing/exporting the configuration of Goals and Tasks.
To find out how to do so, I looked at the (interesting) Community Documentation about "Exportable configuration". Part of what is included there is this:

... two proven and documented APIs exist in Drupal contrib that greatly facilitate the process.

Entity API exportables. If your data is an entity type, you can use the Entity API module to make your data exportable. ...
CTools exportables. CTools can be used to provide exportables support whether or not your data is an entity type. ...

Since Goals and Tasks are both entities, it seems that I'm lucky: I can pick either one. However these are my questions to actually decide about which one to select:

Are there any pros/cons or dos/donts for using either of these APIs to create my exportables?
Which of these APIs appear to be the most appropriate for what I want to achieve?


texts:
I am trying to add a new bundle field into my custom entity, I added the following code into the MyCustomEntity.php file, I uninstalled my module, so, I installed it again, the field is showing up on the view, but in my data base the field is not added.
Could you please support me?
$fields['new_name'] = BaseFieldDefinition::create('text_long')
  ->setLabel(t('New Name'))
  ->setDisplayOptions('form', [
    'type' => 'text_textarea',
  ])
  ->setRevisionable(TRUE)
  ->setTargetBundle($bundle);

Thank you, I will really appreciate your support.


texts: How to display the room resources in a week view of a Full Calendar

texts:
I need to show the room booking in the weekly list.

I've created a node type called 'booking'.  The node has three fields, start date - end date, title and room name.  The room name is assigned as the taxonomy field.

I want to list the room booking in the calendar as below.

The full calendar is installed in my site.  The weekly calendar format is set.  Yes, it can show the booking clearly, but it can show the booking of individual room only.

I've searched both calendar and room reservation modules.  They cannot meet our requirement.

Is there any way or module to do it?   Please help.  Thanks.

After applying the views_field_view according to the comment ->


texts:
This my SQL query to fetch the details.

$query = "SELECT DISTINCT TITLE, PID, TYPE, SUM(DAYCOUNT) AS tot, ROUND(SUM(DAYCOUNT)/(
        SELECT SUM(DAYCOUNT) FROM REPORT_LIST_VIEW), 4) AS per
        FROM REPORT_LIST_VIEW
        WHERE DAYCOUNT > '0'
        GROUP BY TITLE, PID, TYPE
        ORDER BY TITLE ASC";
        $res = db_query($query);

I am displaying out put like this

foreach ($res as $row) {
$i++; ?>

<a href="/page-file-views-user?id=<?php echo $row->pid ;?>&type=<?php echo $row->type; ?>" >

<?php echo ucfirst($row->title); ?>

<?php echo $row->per * 100; ?>%

<?php echo $row->tot; ?>

<?php $sum+= $row->tot; } ?>

How can I add a pagination (mini pager) at top & bottom of the result?

<?php
function pager_array_splice($data, $limit = 9, $element = 0) {
  global $pager_page_array, $pager_total, $pager_total_items;
  $page = isset($_GET['page']) ? $_GET['page'] : '';
 // Convert comma-separated $page to an array, used by other functions.
  $pager_page_array = explode(',', $page); // outs puts empty array
  // We calculate the total of pages as ceil(items / limit).
  $pager_total_items[$element] = count($data); // output 1
  $pager_total[$element] = ceil($pager_total_items[$element] / $limit); // output 1
  $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));  // no output
  return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}
?>

And in my pagination div

$output = '';
$customArr = pager_array_splice($data, 1);
$output .= theme('views_mini_pager', array('quantity' => 1));
print $output;

But no result is printing. Any error in my logic.


texts: How can I hide nodes from view, but open access to JSON:API at the same time?

texts:
I would like to use Drupal as a decoupled system, sourcing its content by using Gatsby.
Having set it all up, I would like my Drupal nodes not to be accessed by random unauthenticated users so I removed the permission from 'View Content'.

Having done that now I can't access the content by my Front end service which uses JSON API (unauthenticated of course).

What's the method to remove the node pages from the site and leave only the admin backend, while allowing to access the content using JSON API ?


texts: How to get parent node from a attachment in drupal8 search api results

texts:
I have apachesolr index search with Search API attachments. In the results I get a link to the file but I would like to get a link to the parent node. I tried in the view but there is no such field with relationship to file usage.
I wrote the following in a module to override the field fid in the view but it returns an error

function hook_preprocess_views_view_field(&$variables) {
$view = $variables['view'];
$field = $variables['field'];
    if ($view->storage->id() == 'saa' &&
    $view->current_display == 'page_1' &&
    $field->field == 'fid') {
        $fid =  $variables['output'];
        $file = \Drupal\file\Entity\File::load($fid);
        $file_usage = \Drupal::service('file.usage')->listUsage($file);
        $variables['results'] = $file_usage;
    }
}

It returns

  The website encountered an unexpected error. Please try again later.
  TypeError: Argument 1 passed to Drupal\file\FileUsage\DatabaseFileUsageBackend::listUsage() must implement interface Drupal\file\FileInterface, null given, called in /home/rebecca/public_html/new5/modules/pdf_app/pdf_app.module on line 262 in Drupal\file\FileUsage\DatabaseFileUsageBackend->listUsage() (line 123 of core/modules/file/src/FileUsage/DatabaseFileUsageBackend.php).


texts:
Drupal does cache Twig templates. Normally, it is a good thing, as long as you don't have a multilingual site.

In my case every t()is not working as the template is cached in the wrong in English, giving German no chance to ever be outputted.

Is this the proper way to deal with t() calls?

 $settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

It seems a bit wrong. As I understand these settings are more for the development process, not for production. Also there really should be a setting to use caching in a language specific way.


texts:
I am looking for a way to add a class to the  week row indicating whether the week is the current week.

The week is rendered by calendar-month-row.tpl.php and the arguments are passed within calendar_build_month().

What is the "Drupal way" of intercepting this procedure?

I of course do not want to hack the module to generate the desired output.


texts: Using views to find list of users nearby using location in arguments

texts:
I am using drupal 6.X
I am creating an api through views and views datasource module
in which i will add the latitude and longitude of the location in the end of the url as we define the arguments in the view so that i can get the list of users in the order of the nearest first.


texts: How to get vocabularies for an entity reference to a taxonomy?

texts:
So I'm having a bit of a difficult time finding out how to get the information I want.

I have an entity reference field - call it field_event_type. This is an entity reference to a taxonomy. I am trying to programmatically get the possible vocabularies associated with this entity reference and get the fields/properties associated with them. Basically walking each of the bundles to get their relevant information.

So far I can get the field definition on the parent node, which looks like this:

Array
(
    [uuid] => 32eeda5f-270f-477d-b24c-75ed15e69b2a
    [langcode] => en
    [status] => 1
    [dependencies] => Array
        (
            [module] => Array
                (
                    [0] => node
                    [1] => taxonomy
                )

        )

    [id] => node.field_event_type
    [field_name] => field_event_type
    [entity_type] => node
    [type] => entity_reference
    [settings] => Array
        (
            [target_type] => taxonomy_term
        )

    [module] => core
    [locked] =>
    [cardinality] => 1
    [translatable] => 1
    [indexes] => Array
        (
        )

    [persist_with_no_fields] =>
    [custom_storage] =>
)

By doing this:

\Drupal::config('field.storage.node.field_event_type')->get();

Based on this link:

field_info_field() deprecated, what's the equivalent?

But I'm not sure how to get the vocabularies or even if that's the right thing to do to get the information I want.

How would I go about getting the vocabularies? I should be able to just load by VID and get the correct fields at that point, correct?


texts: Update to 7.39 and multiple textfield appears in default value

texts:
Updated Drupal core to 7.39 and in field default value, two textfield appears, one empty and another with a value of "t".

Attached is the screenshot of the issue.


texts: Get the highest Matched output in result

texts:
I have a table like this

Now my requirement is like below:-

I have to fetch all Content ID related to User Id-31. Here the matching content id are 225,178. I am able to retrieve this. Now I want to do the following:-

I want to get all user id whose Content ID matches with Content ID of 31 in Decreasing order. It means that if all content id matches then it will appear first otherwise  it will appear last. Here User ID 20 matches 2 times,User Id 19 matches 1, User ID 1 also matches 1 times.  So Result set will be User ID 20,19,1. Now I want to achieve this in Mysql as well as db_select in Drupal 7.


texts: What is the value returned by theme_get_registry, and why is it not NULL?

texts:
I was going through Drupal code, and in the theme.inc file I found something that I couldn't understand. On theme(), I see the following code:

if (!isset($hooks)) {
  init_theme();
  $hooks = theme_get_registry();
}

theme_get_registry() is defined as follows:

function theme_get_registry($registry = NULL) {

  static $theme_registry = NULL;
  if (isset($registry)) {
    $theme_registry = $registry;
  }
  return $theme_registry;
}

I found the function is calling without any parameter, and the default parameter is NULL, but when I use print_r($registry) in the first line of the function theme_get_registry(), I get the values popped out; I assume the value should be NULL because it is not passing any value, and default value is NULL, from where $registry got values in the first line.


texts: I was recently introduced into the Profile2 module for adding fields to the registration process and I think it just solves my problem. Can anyone show me how to theme the fields? All I need are the .tpl files but I don't think there are any since it's form so it uses the Form API. I may be wrong though.


texts: Forms API: 'file' or 'managed_file' type with multiple/unlimited values

texts:
I've got a form that needs to have either a 'file' or 'managed_file' type field in it for uploading files via the form. Is there an attribute that can be set on the form item render array that will allow multiple/unlimited files to be uploaded via the one form item?

For example, when you add a new field via the admin UI to a content type, select the 'file' type widget and then in the field settings set the number of values to 'unlimited' - that's the sort of behavior I'm looking for in this file field via the forms API. Thanks in advance for any pointers!


texts:
How can I alter the key/value items of a checkboxes component in a webform?
I've followed this answer and I successfully altered a select list component for both render and submission.
I'm trying to do the same with a multiple choice component, but although the form is rendered correctly, the values are not saved on submission.
This is my code:

function my_form_webform_client_form_30_alter (&$form, &$form_state) {
    $form = mycustom_form($form);
}

function mycustom_form($form){
     $form['#validate'][] = 'mycustom_webform_validate_form';
     $form['#submit'][] = 'mycustom_webform_submit';
     dpm($form['submitted']['code']['#options']); // ('0'=>'a value', '1'=>'another value');
     $codes = array('foo', 'bar');
     foreach ($codes as $key => $value) {
        $form['submitted']['code']['#options'][$value] = $value;
     }

return $form;
}

function mycustom_webform_validate_form($form, &$form_state) {
dpm($form_state['values']['submitted']);
// selecting all checkboxes I get all the four values
}

function mycustom_webform_submit($form, &$form_state) {
  drupal_set_message('<pre>' . print_r($form_state, true) . '</pre>');
// only 'a value' and 'another value' are submitted
}

UPDATE
I even tried to add some values to the initial form and manipulate them programmatically.
The submission result is like no manipulation was done.
I update my code for a better explanation.

UPDATE 2
I've tried dumping the submitting form.
I updated my code with the results.

UPDATE 3
I confirm that removing the "Multiple" flag from the component, causes the issue to be fixed.
Unfortunately I need a multiple answer, so I can't remove it.

UPDATE 4
This is another solution I'm trying, using hook_webform_select_options_info():

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

   if (function_exists('_mycustom_users_options')) {
        $items['code'] = array(
        'title' => t('User codes'),
        'options callback' => '_mycustom_users_options',
      );
 }

  return $items;
}

function _mycustom_users_options() {
  $output = array();
  $codes = mycustom_user_codes(); // <- these values are based on logged user
  foreach ($codes as $key => $value) {
    $output[$value] = $value;
  }
  return $output;
}

function mycustom_user_codes() {
      $result = // a db query based on user id;
      while($usercode = db_result($result)){
         $output[] = $usercode;
      }

      return $output; // array({[0] => 'a value', [1] =>'another value'})
}


texts: Is it possible to use features or some other technique to compare two sites?

texts: I have a virgin copy of Open Outreach running alongside a copy where I've made configuration changes such as site name and configurations of various modules. Is it possible to use Features or some other technique to discover and document changes I've made?


texts: How to show language specific search result in Solr search

texts:
We have configured solr search in one of our site.The site is multilingual and having 5 languages content in it.

The problem we are facing is, when user language is selected as french and any searches are performed then the search result is not showing french content at top.

We want the users current language content to be populated at top.
Any module or solr settings which we missed.


texts:
Currently, I am using the following code.

/**
 * Implements hook_theme_registry_alter().
 */
function MY_MODULE_theme_registry_alter(&$theme_registry) {
  // Defined path to current module.
  $is_admin = Drupal::service('router.admin_context')->isAdminRoute();
  $node = \Drupal::routeMatch()->getParameter('node');
  if (isset($node)) {
    if ($node->getType() == 'MY_CONTENT_TYPE' && $is_admin == 0) {
      $module_path = drupal_get_path('module', 'reveal_js');
       $theme_registry['html']['path'] = $module_path . '/templates';
       $theme_registry['page']['path'] = $module_path . '/templates';
    }
  }
}

This works, but when going to another page, I have to rebuild cache in order for it to re-evaluate whether the node is 'MY_CONTENT_TYPE' or a different type.


texts: Using Drupal 8 Ckeditor Core plugins -> drupalimage/drupalimagecaption how do I make an image caption required? The checkbox shown should always be clicked.


texts: What is the "Category" argument in user_save for?

texts:
I'm working on a custom module that edits the user's details. I'm using

user_save($user_entity,$new_field_values);

But I see there is a third argument in user_save called "category". What exactly is it for?


texts:
Table field 'Manufacturer' is set to sort by ascending or descending and when you sort it. At first it looks like it's sorting by alphabet, it starts with A, B, C etc. but eventually ends up with A again at the bottom?

The Manufacturer field is a taxonomy term. I can recreate that on a new view just with this field and it still won't sort. Title field sorts fine.

update Looks like you can't sort a taxonomy term alphabetically in a Table View, to reproduce that just create a random view for a content type that has a random taxonomy field that is limited to 1, so you can enable Sort in the Table settings. And if you try to sort, it makes no sense, not alphabetical at all.


texts: How to apply an image style based on a condition?

texts:
I've been following this discussion: How to apply an image style based on a condition (a date for ex.)? but unfortunately it has not been a success.

I would like to have the image to change based on a boolean field type being checked or not. When I check the On Sale checkbox, I would like the product image to be displayed with a different image-style.

My boolean field is named field_commerce_saleprice_on_sale.
1st image style is product_grid.
2nd image style on_sale.
In node--product.tpl.php I found the line

Thanks in advance for your help.


texts: How to create a custom table containing data to be rendered using the Views module

texts:
I have a module which is pulling in some remote data. this is only temporary as long as page is opened i dnt want to store the data on my drupal site. is there a way i can create a custom data table in order to render my data results using the views module.
i looked into hook_views_data()but it seems this only works with database table in the drupal system


texts:
I need to create AND in Contextual Filter, for instance:
I Want to Get All English Node AND Italian Node, with particular Taxonomy.
But I Can Have En and It, but even only en or only it, or even it, en ,de etc

Can I do it with Contextual Filters?


texts:
I am wondering if there is a way to do the following.

I need to alter view return data and either remove entries or keep entires based upon running some PHP.

Is there any easy way to do that? I was looking at the theme stuff, but that would mean I would nuke my pagination, is there anyway I could remove results but regenerate my pagination.

Sorry if this is confusing...

Edit: It's a little difficult to explain, but I am using Commerce. And I need to get a list of discounted products. But commerce only discounts products before they are displayed (ie there is no database I can join/where on to get discounted products). So I need to get all the products, then remove those that are not discounts.


texts: Horizontal Tabs rendered as rendering collapsible fields

texts:
Although I have set up the a Content Type's display to use Horizontal Tabs

It's rendering as collapsible fields:

Does anyone have ideas on how to correct this?


texts: How to display flags to anonymous users and redirect to login after clicking a flag?

texts:
I want to display flag to anonymous user and upon clicking the user should be redirected to register/login page.

I found one answer to this problem in the question about
"How to display a flag to anonymous users?".

I tried this solution but did not work, may be I did not put the code in correct place?

I am using Bartik as my template and I put the code in node.tpl.php.

Any suggestions?


texts: Is it possible to disable (or reject) selection of parent terms in taxonomy reference fields at node creation or edit?

texts:
for instance, for a particular Vocab. and User Role..

Is it possible to achieve that in code? That parent terms will be rendered only as labels and not checkboxes?

Thanks.


texts:
I have an error Notice: Trying to get property of non-object in function MY_MODULE_form_comment_form_alter()
This error is related to the line if ($node->nid == $comment->nid)  and I think to $comment->nid

I suppose that it is needed to describe $comment->nid  as an object like for $node->nid an expression $node = menu_get_object() was used. I was searching for this similar program code and with no success.
I have to use $form['#attributes']['class'][] = 'new-comment-form';  and that is why hook_form_alter is used.
Maybe there is another solution to this problem?

The code is:

function MY_MODULE_form_comment_form_alter(&$form, &$form_state, &$comment_count, &$comment) {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (isset($node->uid, $GLOBALS['user']->uid) && $GLOBALS['user']->uid == $node->uid && $GLOBALS['user']->uid > 0) {
        $form['#attached']['css'] = array(
          drupal_get_path('module', 'MY_MODULE') . '/MY_MODULE.css.');
        }
    }

    $node = menu_get_object();

        if ($form['#node']->comment_count == 0 ){
        // hide a field
            drupal_add_css(drupal_get_path('module', 'MY_MODULE') . '/MY_MODULE2.css.');
        }

        if ($node->nid == $comment->nid) {
            $form['#attributes']['class'][] = 'new-comment-form';
        }

}


texts: How can I collect data through a drupal form?

texts: I want to allow users to contribute posts to my site. Should I set up a content type that can be created by the public or set up a new user role and get people to sign up first? I want to reduce the friction of adding a post to the absolute minimum.


texts: How do I display a view content for a specific user?

texts:
There are several views to show the content that is restricted by the page_access module. For now, the view shows all the content. Ideally, it must show the content that the specific user is allowed to see.

How can I achieve this?


texts: Deleted content returns over and over again

texts:
I have a situation where I can delete (update options > delete selected content) in admin > content...and it says it deletes all the selected records.

But then later on all those records will return again. After I delete them they are not showing at all in (admin > content). But then later, they will show up again there and the links will be clickable etc. It will be like I never deleted them. I can do this over and over again and they keep re-appearing. We're talking about 50 nodes here.

I haven't updated the database otherwise. I've gone to a page (such as search) where those used to appear and they appear again there...and sometimes it seems like maybe that has something to do with it. But I still don't understand what or why.

Is there a better way to delete content to ensure its completely gone?


texts:
When blocking access for a editor role to the view admin/content, all sub-items of the toolbar content item are not visible to this role.
How to solve this ?


texts: wysiwyg ckeditor inline styling not working

texts: I'm using wysiwyg api with ckeditor, but I can't make it to use inline styles like when I use indent from editor, it actually drops the style (which is margin-left) in output. it's not an override, it actually doesn't even appear in the code when I inspect it.


texts: Decide which modules to enable / disable in make file

texts: I have a make file in which modules are downloaded, but how do I decide which ones are enabled?


texts:
I'm using the PDF Reader module to try to display a pdf file. Ideally I'll use the Goolge Viewer, but as of right now none of the displayers display my pdf.

My pdf file is set to full chmod 777 as well as the directory containing it (site/default/files/), for testing purposes only right now just to make sure the error wasn't due to permissions.

Here is screenshot of what I'm seeing -

I can click the 'try downloading the file here' link and view/save the file.

Any ideas?

EDIT: The screenshot is from a dev server connected to the internet.


texts: How to set the sliding image as a background image?

texts:
I'm using Views Galleriffic module in D7 site. Also I got the slider as i needed but still one more thing I need to work, i.e I wanna to set the sliding image (large image) as a background image.

I added the image field in views and added again the same image field in this field i rewrite the output as
field 1;
. It doesn't works.

And also tried that rewriting the image field1 as (without adding it second time)

&nbsp;

This also doesn't works.

If anyone knows,please share your answer and let me know.


texts:
How can I add a block to a region using Drush?

I'm using Drupal 7.0 and Drush 4.3.


texts:
My goal is to switch between different view modes based on the node path (pattern). In my case, the patterns would be:

dossier/node-alias => default template
dossier/node-alias/cover => cover template
dossier/node-alias/abstract => abstract template

I have created the custom view modes with hook_entity_info_alter (simplified here to only one custom view mode):

/**
 * Implements hook_entity_info_alter
 */
function dossier_config_entity_info_alter(&$entity_info) {

  $entity_info['node']['view modes']['cover'] = array(
    'label' => t('Cover view mode'),
    'custom settings' => TRUE,
  );
}

Here is how I declared the path pattern in hook_menu:

/**
 * Implements hook_menu
 */
function dossier_config_menu() {

  $items = array();

  // Cover entity view mode
  $items['dossier/%/cover'] = array(
    'title' => 'Default title', // overridden in template.php preprocess_node function
    'page callback' => '_dossier_config_switch_viewmodes',
    'page arguments' => array(1, 2), // arguments from uri are 1 => node alias and 2 => cover
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

And here is my custom callback:

function _dossier_config_switch_viewmodes($alias, $view_mode) {

  // Get the node path based on the alias
  $path = drupal_lookup_path('source', 'dossier/' . $alias);

  // Return the node if the path exists
  if ($path !== FALSE) {

    $node = menu_get_object("node", 1, $path);
    $node_view = node_view(node_load($node->nid), $view_mode);

    return array(
      'content' => array(
        'node' => $node_view,
      ),
    );
  }

  return drupal_not_found();
}

It works. However, when looking at these nodes in the custom view modes, I lose the node edition tabs (View, Edit, Translate, etc.) and I also seem to lose all the standard classes that are added to the <body> such as node-type-xxx or page-node-12345 etc.

I believe that this is a normal behavior with such a custom callback in hook_menu (?). So what would be the right way to achieve what I want?

Any help on that will be highly appreciated! Cheers!

Edit: I forgot to mention that of course I have 3 different node templates and that I have added the theme_hook_suggestions accordingly in my theme template.php.


texts: Role Hierarchy and Management of Assigned Users

texts:
I need to set up a role hierarchy like this:

Super Admin - Full permissions, can manage all users and content

Regional Manager - can manage only his/her own Store Managers;
cannot manage another regional manager's Store Managers. Can manage
those users' content as well.

Store Manager - can manage only his/her own employees; cannot manage another store manager's employees. Can manage those users'
content as well.

Employee - the low-end of the totem pole. All they can do is create content of a certain type.

How can I go about setting that up?

Thanks!


texts: How to alter rendered commerce line item on order entity view?

texts:
I need to add a column(a "checking logistics picking" link) to each line item on order page(i.e. user/%user/orders/%commerce_order page), but I cannot make it done.
I tried hook_entity_view_alter and hook_block_view_alter, but seems they can only alter order entity view, cannot alter line items part of the order.

How to alter line item on order page?
It became urgent, please help! Thanks.


texts: How do you find where a module's directory is located?

texts:
I have the following:

I want to find where the module "commerce_physical" is located in the modules folder, but I can't seem to locate this module. I did a find and a grep to locate where its files might be, but that doesnt seem to work. What are some other ways to find the location of a drupal 7 module?


texts: Search log module not capturing the search keyword from a custom module

texts:
I have a custom module for apache solr search for a particular taxonomy term - it does some custom search operations.

I want to log these search keywords to be included in search log results. Can you help me with that?

I tried adding hook_search_info() in my code with standard definition - as search log module picks up data from this hook - below is the code I have added. Please help if I am adding wrong code or some other configuration needs to be done.

Also, added this module in search log configuration page to log

function modulename_search_info() {
  return array(
    'title' => 'Content',
    'path' => 'node',
    'conditions_callback' => 'callback_search_conditions',
  );
}


texts:
All,

I complete Drupal 7 newbie here.

I am tackling the themeing of our website (using Adaptive/ Sky theme). Now previously I would have loaded up all the CSS files in the sky.info file but then read that all the stylesheets in theme info file get loaded on every page.

What I want is to load each unique page's CSS on that page only. Example being the 'Home Page' would have its own unique CSS, same for 'About Us', 'Contact Us' pages etc.

As per my research, I am meant to use 'drupal_add_css' function in the template.php file, however, I dont know PHP & have no idea how to add the if condition that each page's alias should dictate which css file is preprocessed & loaded.

Any guidance would be great.


texts: Title Patterns was printed in exactly its self

texts:
Look at image:

If you look to image, you will find a [current-page:page-title] | [site:name] patterns was printed, not replaced to real site name & node title ...etc, I dont know what is wrong was happens...

Token module, Page-title module was enabled, also when i try to change
 PATTERN, its give me an error
 invalid tokens: [current-page:page-title], [site:name].  invalid tokens: [current-page:title]  invalid tokens: [site:name], [site:slogan]. (for front page)

Also, Im clear cach, and run a cron, and trancate table cashes from database manually ....

thanks a lot


texts: pass variable from custom module file to twig template in d8

texts:
How to pass variable from controller to twig template in Drupal-8?
I have tried to pass variable on module theme folder, but I want to use this variable on global theme?


texts:
I have developed a separate functionality using PHP in a sub folder of my Drupal site (e.g. mysite.com/myfolder/myfunc.php).

Now I want to send emails using Drupal functions. Since this is not a custom module I can't use hook_mail().

How do I send an email through Drupal?


texts: No Link to OG Group Home in Group Details Block

texts:
Hello this is a problem thats always perplexed me. I once got around it by using Custom Breadcrumbs and having a link to the group home page there but since then ive had to remove custom breadcrumbs module and i think i would prefer another way of doing things.

Here's a post for example-
http://onlinebanter.com/diary/komps-daily-drivel/vietnam-saigon

As you can see there is no way to navigate back to the group home 'komp's daily drivel' after viewing that group post. I belive years ago and maybe many themes ago the group name on the group details block used to link back to the group the post belonged to. Now it doesn't seem to do so.

Does anyone have any suggestions?

Thanks

Reg


texts:
I have a select field for a content type which has options generated dynamically. The options are updated in hook_form_alter(). The problem is that when I try to manipulate the posted data in submit callback, the field values are empty. Below is an example to better understand the issue.

function my_form_alter(&$form, &$form_state) {
    $options = array('a' => 1, 'b' => 2, 'c' => 3);
    $form['my_field'] = array(
        '#type' => 'select',
        '#title' => t('Label'),
        '#multiple' => TRUE,
        '#options' => $options,
        '#default_value' => '',
    );
    $form['#submit'][] = 'my_submit_handler';
}

function my_submit_handler($form) {
    echo "<pre>";
    var_dump($form['my_field']);
    echo "</pre>";
}

If I select options 2 and 3 for example; the var_dump returns empty array().


texts: Installed Commerce Drupal 7 with Examples but Cannot create Add a Product Action for new Product line

texts:
I am sure this is a newbie question and I apologize in advance but I have spent most of the day trying to solve this problem.

From the examples that I have seen, apparently creation of a product type (Home->Administration->Store Settings->Product Settings->Product Types->Add product type) should result in the automatic creation of a link for that product type in the Add a Product menu (Home->Administration->Products->Actions->Add a Product).

It is not doing this for me. More than likely I am making a basic mistake somewhere but I can not find what it is.

Would greatly appreciate some guidance and advice.
Thanks!
Jim


texts:
I have a weired issue and no idea how to address it. I use a block view on my front page that displays a gmap. When the page loads the map is displayed correctely. When I zoom in or out the map doesn't load (sometimes it loads one or two levels, sometimes no level). The weired thing is, when I use the exposed filter for that view and the gmap loads again (using Ajax), the zooming works just fine. So it seems that when the map is getting loaded again it works but not if the page gets refreshed.

The site I'm talking about is www.my-business-location.com.

BTW: Other gmaps that I use with the gmap field module work well.

Does somebody have an idea what causes this behaviour or how I could find the mistake?


texts: How do i add custom jquerry script to omega theme?

texts:
I found this code:

 (function ($) {
 Drupal.behaviors.betterExposedFiltersExpandCollapseNested = {
   attach:function (context, settings) {
     // first collapse the children
     $('ul.bef-tree-child').css('display', 'none');
     $('.form-checkboxes.bef-select-all-none li').has('ul').once('bef-tree', function () {
       $(this)
         .find('input.form-checkboxes:first')
         .click(function() {
           $ul = $(this).parents('li:first').find('ul');
           if($(this).attr('checked')) {
             $ul.slideDown('fast');
           }
           else {
             $ul.slideUp('fast');
           }
         })
     });
   }   } }) (jQuery);

for expandable hierarchy filters from here

I have no idea how to put it in my theme, what files and how to edit. Anyone could tell me the steps to do that?


texts: Drupal7 Get results from a form in a table

texts:
I want to show my result from the form in the table on the same page.

//my form
function find_tryk_filter_test_form_page($form, &$form_state)
{
$form['submit']         = array(
    '#type' => 'submit',
    '#value' => t('Find trykluft element'),
    '#ajax' => array(
        'callback' => 'find_tryk_filter_test_ajax_result_callback',
        'wrapper' => 'result-wrapper',
        'method' => 'click'
    )
);

return $form;
}

My page callback function

function find_tryk_filter_test_page()
{
  $page = drupal_render(drupal_get_form('find_tryk_filter_test_form_page'));
  $page .= filter_elementer_rows($form_state['values']['dropdown_third']);
  print_r($page);
  return $page;
}

The function that retrives my data and create the table

function filter_elementer_rows($value_dropdown_third)
{
  $header = array(
    'Navn',
    'Shoplink',
    'Brochure'
   );
  $query  = db_query(//Some sql statement...));
  $rows   = array();
  foreach ($query as $row) {
    $rows[] = array(
        $row->title,
        $row->field_shoplink_value,
        $row->uri
    );
}
  return theme('table', array(
    'header' => $header,
    'rows' => $rows
  ));
}

My submit function

function find_tryk_filter_test_page_submit($form, &$form_state)
{
   return find_tryk_filter_test_page();
}

My problem is that when I run this, I get absolutely nothing in the table. And the SQL does work. Do I miss anything?


texts:
I need to retrieve all nodes where updated date is between date A and date B.
I had a look at contextual filters and they seem to allow only the equality operator (SELECT where date = X) whereas I need greater than and lower than operators (SELECT where date > X).

Any idea to achieve this? Any help would be much appreciated.
Thanks!


texts: Drupal 7 - Services Module - Updating a user field with XML

texts:
I will try to convey this with as much detail as possible. I am trying to update a field I added to the user. Let's call the field field_test_field, it is an integer field.
This is what I'm doing so far.
1 Getting CSRF token at http://example.com/services/session/token which gives me something like Dgn6vINkdJUrqFj1XUG_DbWc6PKLxkhdgoB-z3BBsRg
2 Log in my user at http://example.com/rest/user/login.xml
headers are:
Content-type: application/xml
X-CSRF-Token: (token from #1)

Post body:
<?xml version="1.0" encoding="utf-8"?>
  <username>user</username>
  <password>mypassword</password>
</xml>

That works dandy, I get my user object and I'm logged in.
3 (this is the trouble), I want to update the field for my user.
I'm doing a PUT to http://example.com/rest/user/[uid].xml
Headers:
Content-type: application/xml
X-CSRF-Token: (token from response user object on #2)

This is the body
<?xml version="1.0" encoding="UTF-8"?>
<data>
<field_test_field>
  <und is_array="true">
    <item>
      <value>3434</value>
    </item>
  </und>
</field_test_field>
</data>

Yet the response comes back mutilated.
<?xml version="1.0" encoding="utf-8"?>
<result>
<field_test_field>
  <und is_array="true">
    <item></item>
  </und>
</field_test_field>
<uid>5</uid>
<roles is_array="true">
  <item>authenticated user</item>
</roles>
</result>

Doing stuff like x-www-form-urlencoded and putting field_test_field[und][0][value] works fine while testing, but posting actual XML makes me feel like I'm just missing some small detail in syntax. Any help would be greatly appreciated.


texts:
Wanting to use a mobile savvy html5 theme, I currently chose Adaptive Themes "Corolla", however I have noticed over the past 3-4 days that when I now attempt to add any content to Panel, the Panel interface just hangs and shows the blue 'timer' graphic and goes no where even after 10 minutes. If I revert back to say Bartik and or standard theme it works as expected. Since I'm 'upskilling' with a view to future employment, I would like to know what causes such issues now of for future reference, what is is hanging on for?

Of course, cosmetically Corolla can be changed for a custom HTML5 theme, but an answer would be helpful. I'm running a webdev Ubuntu LAMP stack on a home webdev box using pure apache so no wamp/xammp etc. The webdev box emulates a live production server for future commercial projects.

The module versions are:

cTools: 7.X.1.0 alpha#1 (doesn't matter if it is later).
Panels: 7.x.3.0 Alpha#2
Views: 7.x.3.0 alpha#1

I have tried a number of the above versions and I have multiple D7 projects on my LAMP box, and it makes no difference so I have concluded it is Corolla, even with the latest strain. I have no desire to go down to Drupal v6.
Thank you.

Paul B.


texts: How to pass variable from WidgetBase to .module

texts:
In Drupal 8 my module looks like this.

<?php

function signature_field_theme() {

  $theme = [];
  $theme['signature'] = [
    'render element' => 'element',
    'variables' => array(
      'sign_src' => NULL,
      'text_area_id' => NULL,
      ),
  ];
  return $theme;
}

function signature_field_page_attachments_alter(&$page) {
  $page['#attached']['drupalSettings']['signature_field']['sign']['id'] = 'id';
}

My SignatureWidget.php file looks like this...

<?php

namespace Drupal\signature_field\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\ElementInfoManagerInterface;

/**
 * Plugin implementation of the 'field_signature_field_widget' widget.
 *
 * @FieldWidget(
 *   id = "field_signature_field_widget",
 *   module = "signature_field",
 *   label = @Translation("Signature Data"),
 *   field_types = {
 *     "field_signature"
 *   }
 * )
 */
class SignatureWidget extends WidgetBase {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $value = isset($items[$delta]->value) ? $items[$delta]->value : '';

     //
     //$sign_thumb = array( '#type'   => 'html_tag',
     //                     '#tag' => 'img',
     //                     '#attributes' => array('src' => '', 'id' => 'signature_thumb_test', 'class'=>array('align-right'), 'width' =>'120px', 'height' => '60px' ));

    $field_name = $items->getName();

    /*function getFieldName() {
      return $field_name;
    }*/

    $text_area_id = 'signature_field_' . $field_name;

    $file_upload_help = array(
      '#theme' => 'signature',
      '#sign_src' => $value,
      '#text_area_id' => $text_area_id,
    );

    $element += array(
      '#type' => 'textarea',
      '#default_value' => $value,
      '#attributes' => array(
        'id' => array($text_area_id),
                        ),
      '#attached' => array(
        'library' => array('signature_field/signature_pad'),
                        ),
    );
    $element['#attached']['library'][] = 'signature_field/signature_pad';
    $element['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help);
    //$element['#suffix'] = \Drupal::service('renderer')->renderPlain($sign_thumb);

    return array('value' => $element);
  }

}

How can I pass $text_area_id from the widget to the module in order to use it as a variable in function signature_field_page_attachments_alter


texts:
I have a site which is bilingual (English, Greek).

When I create a view with content, I get duplicate entries of the content.

In the view under Rendering Language I have Interface text language selected for page

I added the Original Language filter to see what is happening and I discovered my content is not showing at all in the view when I set the filter to Greek. When I set the filter to English I get duplicate results. By duplicate I don't mean both languages actually but the English language two times.

I have also checked my nodes and both translations look OK.

I have set the filter to Translation Language and not Original Language and now I can see my content correctly. Is this the expected behavior?


texts: How to set up custom Entity Storage per bundle?

texts: Is it possible to use custom entity storage per bundle? Let's say I have node (entity type) which is called article (bundle). I want to store articles in different storage engine than every other nodes (like recipes). So far I have found no way to store single bundle in different storage engine. I could create custom entity type with custom bundle (that works, yes) but I really would like to use nodes and specify custom storage engine for one of them.


texts: How to update some field of all article nodes programatically and set it equal to its title?

texts:
I have a field name 'field_new' in a content type 'article'. I want to insert the value of node title on this field (all the nodes) programatically.

What I have done to achieve, I am using hook_node_update for this, but it is not updating the field values.

function modulename_node_update($node) {
  $new_value = $node->title;
  $node->field_new[LANGUAGE_NONE][0]['value'] = $new_value;
  field_attach_update('node', $node);
}

It would be great if there are another alternatives to do this.


texts:
I have a custom form and a textarea in it as follows :

$form['fieldset']['email_template'] = array('#type' => 'textarea',
    '#title' => t('E-mail template content'),
    '#default_value' => '',
    '#description' => t('A valid template for email trigger.<b> Please type ":" for variable suggestions</b>'),
    '#required' => TRUE,
    '#cols' => 60,
    '#resizable' => TRUE,
    '#rows' => 5,
    //'#type' => 'text_format',
    //'#base_type' => 'textarea',
  );

When i installed the ckeditor module and enabled it , the following text appears under textarea ,

Then i gave sky:notification/addTemplate.edit-email-template in the visibility settings Fields to exclude/include: after enabling the include option in Use inclusion or exclusion mode:


texts: How do I add a node reference as a apache solr facet

texts: I have used Search API which provided a lot more facets like node reference fields by default as facets. However I had to use solr3.6 and decided to take up ApacheSolr module for this project. I see that it only gives normal cck fields as facets. Do I have to create a custom facet for this?


texts:
I can't find the solution to print (display) Drupal's Node Title in a field group? I want my Node Title in the field group (see image).

In this project I can't use Display Suite. I also can't find a template suggestion for a field group?

How do I manage to do this?


texts: Calendar as view's pager (passing arguments between views?)

texts:
I have a view paged by week. Users are a bit disappointed by the pager: they find clumsy to navigate to weeks that are far in time (more than 1 month from today's date).

The idea is to keep the weekly pager for small jumps in time and add a month calendar, so when you click a day on the calendar, the corresponding week is shown in the view. If this is too complicated, I think that a drop-down with a list of weeks could be enough, at least for now.

I was thinking that a possible solution could be creating two views and display them in one page. When you click a cell in the first view (which shows the month calendar), the date is passed to the second view (the main view, paged by week), which accepts a date as a contextual filter. But is this possible to do?


texts: How to customize home page layout according to the user?

texts:
I have a site with more than 2000 users. Users can log in to the site, can see the content, make it as his favorite etc. My home page (Dashboard of user) has different blocks created of views.

How can I allow users to customize the position of these blocks?

They can show/hide blocks, change the position (region) of blocks, can select which content need to show from the view results, change the sort criteria.


texts: How can I programmatically add a field to a field group?

texts:
I have tried this code but it is not working.

$form['field_test'] = [
  '#title' => t('test'),
  '#type' => 'radios',
  '#options' => [t('A'), t('B'), t('C')],
 ];
$form['#group_children']['field_test'] = 'group_1';

I also tried with

$form['#fieldgroups']['group_1']->children[] = 'field_test';

But nothing is working. It works in Drupal 7. Is it changed in Drupal 8?

I have written this code in hook_form_alter and I'm altering a node form.


texts: Call to undefined function node_mass_update()

texts:
In hook_form_alter(), I am using the following code.

if ($form_id == 'album_node_form') {
  $form['actions']['unpublish'] = array(
    '#type' => 'submit',
    '#value' => t('Unpublish'),
    '#submit' => array('az_alter_unpublish')
  );

  // …
}

In az_alter_unpublish(), I am using the following code.

function az_alter_unpublish($form, $form_state) {
  $nodes = array();
  // $nodes is an array of node IDs for the nodes I want to unpublish.
  node_mass_update($nodes, array(array('status' => 0)));

  // …
}

This returns a fatal error.

I read the function documentation, but I can't find out the problem.


texts:
I need to execute some functions when a field value changes. I tried both Drupal AJAX framework and classical Jquery, but in both cases the callback function is not executed.  Adding a Jquery .change() :

(function ($, Drupal, window, document, undefined) {
  $(document).ready(function(){
    $("#foo").change( function(){
      var selected_date = $(this).val();
      $.ajax({
        type: "POST",
        url: "MYURL/"+selected_date ,
        data: selected_date,
        success: alert( selected_date)
      });
    });
  })
})(jQuery, Drupal, this, this.document);

The Jquery works fine. Then

/**
* Implementation of hook_menu().
*/
function MYMODULE_menu() {
  $items['MYURL/%'] = array(
    'page callback' => 'MYMODULE_get_liberte_id',
    'page arguments' => array(1),
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
  );
  return $items;
}

function MYMODULE_get_liberte_id ($selected_date) {
  //DB queries and form alter or error messages here
}

I also tried with AJAX Framework :

//hook form alter
$form['foo']['#ajax'] = array(
  'callback' => 'MYMODULE_ajax_callback',
  'wrapper' => '.center-wrapper',
 );

function MYMODULE_ajax_callback($form, $form_state) {
  //is the function fired ???
  $commands[] = ajax_command_alert(t('MYMODULE_ajax_callback fired'));
  return '
'.date('Y-m-d').'<xmp>'.print_r($form_state['values'], true).'</xmp>
';
  //DB queries and form alter or error messages here
}

dsm($form) shows that the field got #ajax attribute, but the callback function isn't executed.

I'm afraid I'm not on the right way, or at list I'm missing something :(


texts: Translate simple code snippet - Get taxonomy term id

texts:
im following this great podcast which is drupal 5 (i guess).

I want to add a View into my page--taxonomy.tpl.php and get the id of the taxonomy term im currently looking at. Could maybe anybody translate this code snippet for drupal 7?

<?php
$view = views_get_view('taxonomypages');
$display = $view->execute_display('block_1', 2);
print $display['content'];
?>

I figured out that this shows me the view:

$view = views_get_view('taxonomypages');
print $view->preview('block_1',$tids);

but $tids is undefined.
i need to have the current taxonomy term id that im looking at e.g when im at taxonomy/term/12 the id is 12 but $tids is undefined.


texts: How to count number of field collection items for a row in a view?

texts:
I just want to count the number of field collections items in a row. I am working on a view. In the view I am able to show the field collection items value, but I do not want the value I just want to count number of items per row.

I am trying view aggregate but its showing sql errors.


texts: When should I create a service or a utility function?

texts:
I had this question in mind along all the last week: When I should create a service or an utility function?

In the Drupal Core we have both Services and Utility functions, but I can't find the distinction between them (when I need to create a service or when I need to create an utility function).

I will take as example the Modules Weight module where I have the InternalFunctions class.

<?php

namespace Drupal\modules_weight\Utility;

class InternalFunctions {

  public static function prepareDelta($weight) {
    $delta = 100;

    $weight = (int) $weight;

    if ($weight > $delta) {
      return $weight;
    }

    if ($weight < -100) {
      return $weight * -1;
    }

    return $delta;
  }

  public static function modulesList($force = FALSE) {
    $modules = [];
    $installed_modules = system_get_info('module');

    $config_factory = \Drupal::service('config.factory');

    if ($force) {
      $show_system_modules = TRUE;
    }
    else {
modules.
      $show_system_modules = $config_factory->get('modules_weight.settings')->get('show_system_modules');
    }

    $modules_weight = $config_factory->get('core.extension')->get('module');

    foreach ($installed_modules as $filename => $module_info) {
      if (!isset($module_info['hidden']) && ($show_system_modules || $module_info['package'] != 'Core')) {
        $modules[$filename]['name'] = $module_info['name'];
        $modules[$filename]['description'] = $module_info['description'];
        $modules[$filename]['weight'] = $modules_weight[$filename];
        $modules[$filename]['package'] = $module_info['package'];
      }
    }
    uasort($modules, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);

    return $modules;
  }

}

In this class I have two static functions but they are both utility functions or prepareDelta() is an utility function and modulesList() should be in another class and have a service?

The only difference that I found at this time is that inside the namespace Drupal\Component\Utility (where you will see a lot of utility fucntions) none of them use inside a service and usually a service use another services inside (I don't have review all the services to validate this).

So, when I should create a service or an utility function?


texts:
I am using hook_link_alter(&$variables) to alter links depending on the user's role. I'm doing this for links in the main menu as well as for custom links shown on entities. This works good except caching.
If I change a user's role still the previous behaviour of the altered links is shown. If I clear all caches, it works fine again.

I thought of adding cache context user.roles. But hook_link_alter seems not to support to add caching meta data to $variables see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21menu.api.php/function/hook_link_alter/8.5.x. (Or I'm doing it wrong.)

What can I do to make caching of my altered links aware of the user's roles?

My code looks like in hook_link_alter(&$variables)

$roles = \Drupal::currentUser()->getRoles();

if(!in_array('member_gold', $roles)) {

  $url = $variables['url'];

  if (($url->isRouted() && $url->getRouteName() === 'view.my_content.page') OR ... ) {

    $url = Url::fromRoute('myModule.ajax_callback', ['op' => 'do_action']);
    $token = \Drupal::service('csrf_token')->get($url->getInternalPath());

    $variables['url'] = $url;
    $variables['options']['query']['token'] = $token;
    $variables['options']['attributes']['class'][] = 'use-ajax';

  }

}

Update:

The links that I alter are in a) the main menu, b) in pseudo fields and c) by other modules. I succeeded adding some cache context to a) and b) and skipped c). It seems to work, but I don't know why, it was more or less trial and error:

For the menu links:
    function mymodule_preprocess_menu(&$variables) {

if(isset($variables['menu_name']) && $variables['menu_name'] == 'main') {

  $variables['#cache']['contexts'][] = 'user.roles';
  $renderer = \Drupal::service('renderer');
  $renderer->addCacheableDependency($variables, \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()));
}

In my pseudo fields:

$build['action_my_action'] = [
    ...
    '#cache' => [
      'contexts' => ['user.roles'],
    ],
  ];

  $renderer = \Drupal::service('renderer');
  $renderer->addCacheableDependency($build, \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()));

I don't understand why this works. I initially only tried adding the cache context, but this did not work. Only if I add the dependency to the current user. However I don't know whether this is correct, as I don't want to vary by user but by role.

Would be great if someone can explain me if this is right and why it works?


texts: How to add Retargeting tag into each page?

texts:
I am using drupal - 7.

I wanted to embed <script> tags for Retargeting tag into each page of the Website, between the <body> </body> tags.

I am new to Drupal. I am trying to create custom block module for this.

I have created custom module to place  tags into custom block. I am not sure what I have done is right or wrong. Can any one help me with this?

I just wanted to add script like this into each page for Retargeting tags for campaigns

<script async src="http://i.simpli.fi/dpx.js?cid=0&segment=Segment+Name&campaign_id=0"></script>

I have added script tag into my js file which I have called from .info file.
In my .info file I called;

scripts[] = MyCustomBlock.js

This is the code for my custom block module.

/**  * Implements hook_help().  *  * Displays help and module
information.  *  * @param path   *   Which path of the site we're
using to display help  * @param arg   *   Array that holds the current
path as returned from arg() function  */

function MyCustomBlock_help($path, $arg) {
  switch ($path) {
    case "admin/help#MyCustomBlock":
      return '<p>' . t("Displays links to nodes created on this date") . '</p>';
      break;
  }
}

/**
* Implements hook_block_info().
*/
/**  * Declaring the block  */
function MyCustomBlock_block_info() {
  $blocks['MyCustomBlock'] = array(
    // The name that will appear in the block list.
    'info' => t('MyCustomBlock'),
    // Default setting.
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );
  return $blocks;
}

/**  * Preparing for a module configuration form  * Implements
hook_menu().  */

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

  $items['admin/config/content/MyCustomBlock'] = array(
    'title' => 'MyCustomBlock',
    'description' => 'Configuration for MyCustomBlock module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MyCustomBlock_form'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

/*  * Adding JavaScript from within a module  */

function MyCustomBlock_add_js($data = NULL, $options = NULL) {
    $javascript = &drupal_static(__FUNCTION__, array());
    $jquery_added = &drupal_static(__FUNCTION__ . ':jquery_added', FALSE);
}

I can see my block module in the /admin/modules section and I can enable my custom block module. But, I am not sure how to add that script into my module.

Thanks for the help!


texts: I am using Simplenews module for sending newsletter to users. I have created a view and the view will be the newsletter body. The view has title and images. When I send email to users, images in view are breaking. But other iamges such and footer images are displaying. When inspected the URL itok='' is missing from the image. I am using Mime Mail for email sending. Is any configuration to be made in Mime Mail for displaying the images. Thank You


texts: Is it possible to port a jQuery module using ProtoType.js to Drupal 7?

texts:
I've been the maintainer of an integration module for phpFreeChat since Drupal 5. I ported it to Drupal 6 with no problems, and I tried to port it to Drupal 7, but it hangs when the chatbox starts to load.

phpFreeChat is written with jQuery and the ProtoType.js library. Drupal 7 introduces jQuery into the UI of ALL its pages, and I believe that the reason it won't load is that it is conflicting with this. I looked at the chatbox loaded in Drupal 6 in the Firefox debugger, and then looked at it trying to load in Drupal 7 - both are vanilla installations using Garland theme. The Drupal 7 installation loads 8 jQuery files that are not loaded in Drupal 6. There is a module called Black 'n White that is supposed to let me suppress the loading of JavaScript files and I wanted to see if the chatbox loaded if the loading of these 8 jQuery files was suppressed, but the module didn't work, unfortunately.

phpFreeChat's use of jQuery is extensive - 2 dozen files - and it relies heavily on AJAX. I can't see how to apply the new instructions in Drupal 7 to get around the compatibility problems it introduces to this module. It seems like I'd have to rewrite the entire chatbox program.

If it's possible to port this module to Drupal 7, I'd like to do it. But it appears to me that it's not possible. Maybe, though, I just don't know jQuery well enough to see how to get around the problem. Can someone advise me?


texts: How to enable Google analytics while site is in maintenance mode?

texts:
I want to know how many users visit my site that is currently in maintenance mode. I have installed the google analytics module, but it doesn't add google tracking codes to the maintenance page, so google analytics says "Tracking not installed".

How do I enable it while site is in maintenance mode?


texts: Node access permission but show view teasers and search result teasers

texts:
I use Content Access module and Profile 2 module to restrict access to specific nodes and assign a specific role during registration.

The problem now is that the search results are not visible? How do i manage after you search, the teaser results are visible, but you can't go to the full content of the specific node? Do i have to use other module or another method?


texts:
I'm working on my first module. What I'd like to do is add this table http://pastebin.com/A1cbya5m function's output to the bottom of nodes. I'm not sure how to do this using hook_node_view()'s '#markup' field. I can do one line but nothing this complicated. I tried doing '#markup' => print_payment_table(), but it didn't work.

Any ideas?


texts: I am searching for a function that list all the blocks that are enabled in a theme. Is there any function for this purpose?


texts: Possible to create fields without admin?

texts:
Possible Duplicate:
  Assign Fields programatically to custom node defined by custom module

Is it possible to create fields in code without using admin in Drupal 7?


texts: Vendor directory vs. Modules directory. What are the key differences?

texts:
I've seen articles that instruct developers to add docroot/vendor to the .gitignore but if I require a module with composer and push up that module, will that cause a huge error on the site I'm pushing up to?

Does my composer.json file have to include all of the modules in my modules directory?

If I were to copy and paste the composer.json file into another install and run composer install would that automatically give me all of the dependencies I need?

As you can tell, I'm pretty new to Drupal 8. The team I work with uses Acquia and I'm finding a ton of issues when trying come up with a good workflow using compser, drush, git, and config management.

Thanks


texts: Change autocomplete path with hook_form_alter()

texts:
I'm trying to change the autocomplete path of a node reference field (References module) with a custom module using hook_form_alter().
I have no problem changing any property of the field except the ["#autocomplete_path']. when I set another value for this, the field loses its autocomplete feature. (The hidden autocomplete field isn't there anymore as well) I find this totally weird, and haven't found anything about this in issue queues or anything like that.

Just FYI, I've setup a new MENU_CALLBACK path with hook_menu() and a callback function, so I'll be able to return JSON suggestions depending on some custom parameters and the value of another field.


texts:
I've create Tax Rate of 20% in VAT type of tax.

It is now displayed in the checkout process and in order view.

What I want now is to show the rate i have created, which is 20%, in the checkout and in order?

Any help will be greatly appreciated.

Thank you!


texts: How do I make a block title output as a link?

texts:
I have a couple of Views block displays that are being shown inside of Panels content panes.  I am trying to get the block titles to be links to overview (static) pages.  The devel_themer module suggested that I make a template file named panels-pane--block--views-case-studies-block-block.tpl.php ("Case Studies Block" is the block name.)

When I try to load the page now, I get errors about undefined variables (block_html_id, block).

I think this probably has something to do with Panels and Views templates clashing, maybe?  I'm still getting my feet wet with theming/overrides.  Any suggestions?


texts: How to find out the terms which are not being used for some duration

texts:
I have vocabulary and it contains more terms, so I want to implement purge logic on it. i.e. I want to delete all the terms which are not used for some duration say 1 week.

Example

term1 was associated to node1 on Oct 1st
term2 was associated to node1 on Sep 30
term1 was associated to node2 on Oct 5th

So now term 2 was not being used for last one week, so now I need to delete that term alone.

I have tried following query,

SELECT ti.tid, td.name, ti.nid
FROM taxonomy_index ti
JOIN taxonomy_term_data td ON ( td.tid = ti.tid )
WHERE td.vid =48
AND ti.created < UNIX_TIMESTAMP( DATE_SUB( NOW( ) , INTERVAL 2 WEEK ) )

However this query gives me both term1 and term2


texts: prepare() function doesn't work well in migrate module

texts:
This is my code to move a few records from a table to a Drupal content type (called CT1)

<?php
class CT1Migration extends Migration {
    public function __construct() {
        parent::__construct(MigrateGroup::getInstance());
        $this->description = 'Imports CT1';
        $fields = array(
                'id',
                'subject',
                'content',
        );

        $query = db_select('tbl', 'qf')
        ->fields('qf', $fields);

        $this->source = new MigrateSourceSQL($query);

        $this->destination = new MigrateDestinationNode('porseman');

        $pkmap = array('id' => array('type'  => 'int',
                'unsigned'  => TRUE,
                'not null'  => TRUE,
                'alias'     => 'qf'));

        $this->map = new MigrateSQLMap($this->machineName, $pkmap, MigrateDestinationNode::getKeySchema());
        $this->addFieldMapping('title','subject');
        $this->addFieldMapping('field_CT_body', 'content')->arguments(array('format' => 'full_html'));
    }

    public function prepare($row) {
        $row->title = "This is title 1";
        $row->field_CT_body = t("This is body");
    }
}
?>

CT1 has two fields, title and body. I need to perform some settings before the migration so I use prepare() function. From function prepare($row) function I expect the values of title and field_CT_body of all of the imported records to be This is title 1 and This is body while after the migration the title correctly gets this string (This is title 1) as its value but field_CT_body has no value at all.

if I remove the prepare function it migrates the records successfully.


texts:
I created a view with an RSS feed on my D7 site. From the XML feed I'd like to remove the author who created the node displayed in my view and the creation date. I've searched everywhere and tried everything, but I can't seem to remove these two fields from my feed.

I only have permissions to work in views so if you have a solution using Views 3 I'd be most appreciative.

Thank you!


texts:
Update manager takes me to the page where I select the checkbox for the updates I need. I check the box of the module and then it downloads the update. After the download it tells me I should put my site in maintenance mode with a checkbox that is on by default. The button says "Continue" to install the updated module.

My problem lies after this point. No updates are installed and after clicking "Continue" I get booted to my home page with the message "Operating in maintenance mode. Go online."

So currently the only way to update my modules is manually. Update manager doesn't work for me. Any pointers as to why it behaves the way it does?


texts: Override Theme table function used in contributed module?

texts:
There is function used in Ubercart module :

function theme_uc_recurring_user_table($variables) {
    ........
}

I want to override result of this function and did by below method in template.php file of my theme:

function MYTHEME_preprocess_table(&$variables) {
  global $user;
  if ($user->uid) {
    if (current_path() == "user/me/recurring-fees") {
      if(!$variables['header'][7]) {
        $variables['header'][7] = "Donation";
      }
      if(!$variables['rows'][0]['data'][7]) {
        $variables['rows'][0]['data'][7] = l('Update Donation', '/donation');
      }
    }
  }
}

I just added table column header and data below that. But I did this by current path but I think there must be some right approach.

I am trying to find but not able to figure out how exactly we can achieve this.

Please suggest !! Thanks


texts: Drupal exposed form search term filter giving a SQL error

texts:
I had installed drupal 7 with oracle as database. Its working fine but some query fails. I am attaching the error that i got while searching a term with search term filter in my exposed filter form.

SELECT COUNT(*) AS expression FROM (SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, SUM(search_index.score * search_total.count) AS score, 'node' AS field_data_field_start_date_event_node_entity_type, 'node' AS field_data_field_end_date_event_node_entity_type, 'node' AS field_data_field_short_description_event_node_entity_type, 1 AS expression FROM {node} node LEFT JOIN {search_index} search_index ON node.nid = search_index.sid LEFT JOIN {search_total} search_total ON search_index.word = search_total.word WHERE (( (node.status = :db_condition_placeholder_0) AND (node.type IN (:db_condition_placeholder_1)) AND( (search_index.type = :db_condition_placeholder_2) AND( (search_index.word = :db_condition_placeholder_3) )))) GROUP BY search_index.sid, SUM(search_index.score * search_total.count), node.nid, 'node', 'node', 'node', node.title, node.created HAVING (( (COUNT() >= :search_index_keys) ))) subquery (prepared: SELECT COUNT() AS expression FROM (SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created, SUM(search_index.score * search_total.count) AS score, 'node' AS L#953, 'node' AS L#954, 'node' AS L#955, 1 AS expression FROM "NODE" node LEFT JOIN "SEARCH_INDEX" search_index ON node.nid = search_index.sid LEFT JOIN "SEARCH_TOTAL" search_total ON search_index.word = search_total.word WHERE (( (node.status = :db_condition_placeholder_0) AND (node.type IN (:db_condition_placeholder_1)) AND( (search_index.type = :db_condition_placeholder_2) AND( (search_index.word = :db_condition_placeholder_3) )))) GROUP BY search_index.sid, SUM(search_index.score * search_total.count), node.nid, 'node', 'node', 'node', node.title, node.created HAVING (( (COUNT(*) >= :search_index_keys) ))) subquery ) e: SQLSTATE[HY000]: General error: 934 OCIStmtExecute: ORA-00934: group function is not allowed here (/tmp/pear/download/PDO_OCI-1.0/oci_statement.c:142) args: Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => event [:db_condition_placeholder_2] => node [:db_condition_placeholder_3] => abc [:search_index_keys] => 1 )

Is this a connection issue. My other filters in form works fine.


texts: Are CCK shared fields loaded on node_load()?

texts: field_metatitle is a CCK field that is used amongst 5 different content types, meaning that it is a "shared field". When I do $node = node_load('123');, I see that $node->field_metatitle is not present.


texts: Is it possible to add CSS to theme without a subtheme?

texts:
I am using a contributed theme and I would like to add a bit of CSS.

The theme uses a lot of stuff that isn't inherited by sub-themes (settings, colors, etc), and I don't want to create a sub-theme just for the small amount of CSS I need.

What would you suggest in this case?


texts: Trouble installing drupal-project with Composer

texts:
I have followed the directions to install drupal-project with drupal-composer.
I keep getting this error and it doesn't make sense to me.

  [InvalidArgumentException]
   Could not find package drupal-composer/drupal-project with version 8.x-dev in a  version installable using your PHP version 5.5.38.

I am using MAMP and the php version is 7.1.22. I even tried the template download for drupal-composer/drupal-project and I still get the same error. Composer is installed, verified with the checking the version in terminal.

I have searched and cannot find anything to assist me in solving. Yes, I am new to composer and trying to get a local environment setup with composer versus just downloading etc. Any help or direction would be appreciated.


texts:
I am creating a custom module that has the following as the build:

$build = array(

          '#type' => 'markup',
          '#markup' => $html,
          '#attached' => array(

             'library' => array('pup_viewfiles/sortfiles_libraries'),
            ),
        );

    return $build;

I have a Form that I get with the following line :

$form=\Drupal::formBuilder()->getForm(pup_viewfiles\pager),

The question is how can I incorporate this form into the build ?


texts:
I am developing a custom module and I need to implement a theme. The result of my code below is that the code inside the block does not print because Drupal can't find the theme. I'm using hook_theme() and I'm not sure what I am missing.

Directory structure

jsblock.module code

/**
 * Implements hook_theme().
 */

function jsblock_theme($existing, $type, $theme, $path){
  return array(
      'jsblock_custom_theme' => array(
          'variables' => array('content' => NULL),
          'template' => 'panels_pane__block__jsblock_jsblock',
          'path' => drupal_get_path('module', 'jsblock') .'panels_pane__block__jsblock_jsblock',
      )
  );
}

I've been able to print the block by dropping the the file in the theme templates folder, but not when it is inside the module directory. Can someone please tell me what is wrong with my code?


texts: Rule to create an identical entity to the node created then delete node

texts:
I have a content type called "article" and an entity type called "article 2", they both have identical fields.

When I create an article node and save it I want a rule to fire that then basically creates an exact copy of this as an entity, article 2. then deleted the original node after that. So I am left with a copy of the node as an entity - all fields etc, and no node.

I can get rules to create an entity quite easily by using "Create a new entity" but I can't seem to map the fields from node to entity?