texts: form_set_error: How to set for an array Drupal 6

texts:
Array
(
    [items] => Array
        (
            [0] => Array
                (
                    [nid] => 164
                    [module] => uc_product
                    [remove] => Remove
                    [title] => Strokes1
                    [data] => a:4:{s:10:"attributes";a:0:{}s:9:"shippable";s:1:"0";s:12:"restrict_qty";s:1:"0";s:6:"module";s:10:"uc_product";}
                    [qty] => 2
                    [description] =>
                    [cart_item_id] => 200
                )

            [1] => Array
                (
                    [nid] => 165
                    [module] => uc_product
                    [remove] => Remove
                    [title] => Strokes2
                    [data] => a:4:{s:10:"attributes";a:0:{}s:9:"shippable";s:1:"0";s:12:"restrict_qty";s:1:"0";s:6:"module";s:10:"uc_product";}
                    [qty] => 1
                    [description] =>
                    [cart_item_id] => 203
                )

            [2] => Array
                (
                    [nid] => 166
                    [module] => uc_product
                    [remove] => Remove
                    [title] => Strokes3
                    [data] => a:4:{s:10:"attributes";a:0:{}s:9:"shippable";s:1:"0";s:12:"restrict_qty";s:1:"0";s:6:"module";s:10:"uc_product";}
                    [qty] => 1
                    [description] =>
                    [cart_item_id] => 204
                )

        )

    [update] => Update cart
    [checkout] => Checkout
    [form_build_id] => form-5c5819d5418df14f08153f1ce15d6acc
    [form_token] => 2341b9068b8ffb7454d267b22e572d7d
    [form_id] => uc_cart_view_form
)

I'm using form_set_error to display the error messages if there is no product.

My Issue is:

For example, I am having 3 products in the checkout page.

When I clicks submit I need to validate that all the products are available.

Here, let us consider if the second product is not available I am showing the error message "Product Stroke 2 is not available".

But all the check boxes in the cart is highlighted

Because I had set form_set_error to items element.

How can I set form_set_error for every individual element.

What I have given to display error message:

form_set_error('items', 'Not available');

Kindly guide me how to resolve the issue. I am using ubercart module with drupal 6.


texts: put views block in a content type different than the one in views block

texts:
I have 2 content types. One called "tributes" and another called "offers".
Both content types have a field reference to pages of a third content type called "county".

What i want is to display a view block with content from "offers" in the pages of content type "tribute" based on the value of the field county that appears in the node each time.

Is there a way to create a contextual filter on field county and use as default value the value of the field county appearing in the "tribute" node?? (through PHP perhaps?!)

Thanks in advance!


texts: Unable to login into website after installing and setting up itweak_login

texts:
After installing and tweaking itweak_login I got this error when I tried to re login into the site.

Any body have any ideas, how I can log in into the site. Sorry, unrecognized username or password.

Notice Message:

  Notice: Undefined variable: form_values in _itweak_login_user_login_final_validate() (line 266 of C:\Inetpub\websites\web.etfotvots.com\sites\all\modules\itweak_login\itweak_login.module).


texts: What would be the best way to setup a mobile theme for an existing domain with domain access module?

texts:
We have implemented a multidomain portal using domain access module. Now we would like to setup a mobile site for each domain added.

Initially we thought about going for responsive layout, but as the mobile portal has very simple layout with minimum elements, using responsive model might be an overkill as it load every html elements to mobile even if most of the elements are not used in mobile theme. Also there are few features/blocks like slider etc implemented differently in mobile theme.

The m.domain and separate theme for mobile site looks like a feasible solution. But I am not sure what would be the best way to integrate it with domain access.

We want all content in the desktop domain available in the mobile domain, only theme need to be changed. It would be good if we were able to setup a domain alias where we can provide the m.domain.com in the configuration for the main domain and use the same access control as main domain, only change will be the theme and the links rel="alternate" and rel="canonical"

Also we need to setup a http redirection when a user visit the site from a mobile device. (Any suggestion for switching back to the desktop theme from mobile device and vice versa)

Is there any way to implement something like this using domain access?


texts: Show related nodes of a specific type when looking at a node of a different type

texts:
I have a custom content type Topic, another custom content type Sub-Topic, and a taxonomy Topic Tags.  I'd like to be able to display the sub-topics on the page for each topic that has any of the same topic tags.

I'm using panels to define how pages look topics, and I was trying to use a view for the sub-topics.  I can make a view that filters by a specific tag, but I can't figure out how to pass the tags that the topic node has to the sub-topic view.

Thanks!


texts:
After updating the Panels module to 8.x-4.2, I got the following error whenever I submit any form in the site.

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The "twocol" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /var/www/test_site/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).


texts: How can I disable "Delete the account and its content"?

texts:
On the Cancel account page, is it possible to disable the option "Delete the account and its content"?

Some roles have the permission to cancel user accounts, but they should not have the option to delete the user's content.


texts: Unable to upload video files in drupal 7 with the video module

texts:
I am trying to make a simple video uploading site with Drupal. I am using the Video module. Let me tell you what I have done:

1) Just made a fresh installation of Drupal 7.7

2) Installed the Video module

3) Enabled the following

Video
Video UI

Now when I go to configuration tab I see the following error:

  Exception: You must have the cURL extension enabled to use this
  library. in require_once()  (line 22 of
  C:\wamp\www\freshdrupal\sites\all\modules\video\libraries\zencoder-php\Zencoder.php).

However I can still create a new content type and add field of video type. In that case when I add a content and upload video it gaves the same exception error as shown above.

Please help. If there is any substitute module for doing the same please tell me so. I need it urgently.


texts: How to alter file upload description text

texts:
I'm trying to customize text for a file upload widget in Drupal 8.

Here is a screenshot of the widget:

I just want to display the first 15 MB which I added as file field description text in the content type.

The trouble is the last 3 lines of text have no HTML tags so I can't selectively hide it with display:none;. Here is what I mean:

I tried this CSS but it doesn't work:

#edit-field-dataset-file-0--description * {
    display:none;
}

#edit-field-dataset-file-0--description p {
    display:inline !important;
}

Does anyone have any suggestions?


texts:
I have need to create a page with following information.
Personal Information,
Address and
Contract Information.

One Personal Information will have multiple address and multiple Contract information. I am thinking of creating three content types. The personal information page will have add address and add contract buttons which will popup the respective content type. When the address or contract popup is closed then control is passed to the Personal Information page, here I should be able to view the contact and address information just added in tabular format. I thought it may be a view.

My question is, Is it possible to achieve this kind of work in Drupal 7? If yes how can I do it. It will be nice to have some information so that I can look into the right direction. Some example sites would be help full.

Thanks


texts:
I get 404 errors on file uploads on a D7.19 website. The displayed error is the usual oversized file but I'm sure it's unrelated (see below).

Here is the apache log message :

POST /file/ajax/field_photos/und/form-YJgDfzca9S88uWmWhrE2GGYBM_sIEKXLGvVKQD34xeU HTTP/1.1" 404 1563 "http://dev.domain.com/node/add/animal" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17"

I'm sure the server setup is OK because some other sites hosted on it have AJAX working flawlessly.

Disabling Javascript makes file uploads work OK, so it's definitely some Javascript getting in the way somewhere.

What I tried yet :

changing JQuery version (update or no update)
put the website in english (prod will be in french)
disabling any compression and caching
enabling any compression and caching
disabling some modules (Superfish, dev modules, UI stuff)
different browsers : error is the same everywhere (Safari, Chrome, Firefox).

... and browsed the web like crazy, not finding anything about this precise error.

The only vague hint I have is a file called jquery.cookie whose code doesn't seem to be aliased correctly ((function ($) { // code here })(jQuery); ) but I doubt it could be it.

At this stage, any idea would be welcome. The website is supposed to go live tomorrow (!).


texts: Hide the Drupal /user/register form from spam, but leave open registration to Commerce/Ubercart

texts:
Commerce/Ubercart require account creation to buy product.  That's fine - I want that.

But I do not want user/register open to the public.  Efforts to use Honeypot/Captcha/Mollom are still letting in lots of spam user registration.

What is a hook_form_alter I could use in a module to entirely remove the user/register form and make user/register page blank, without disabling open registration for Ubercart/Commerce?  I would then add a block to this page instructing humans to buy a product to create an account.

Make sense?  Please advise on the code.  THANKS!


texts: Views: Filtering nodes on the basis of logged in user role

texts: Is it possible to filter out nodes with respect to current user role? For example, I want to create a view where users can see the all the published nodes as well as the unpublished nodes they have created. And if current user is a site admin, he should be able to see all the nodes. Is it possible using views?


texts: Why is there quality loss on my image styles?

texts:
This is the original image (610x405)

This is the image after applying image style (scale and crop) to 290x190.

Both image have the same aspect ration, yet there is visible quality loss on downsizing. Am I applying the right image style? What should I be doing?


texts:
My site is sub-divided into organic groups.

Group administrators are allowed to create new users, but I need a way to auto-assign the new user to the same organic group the creating group administrator belongs to.

Can anyone tell me how I can accomplish this auto-assignment either programmatically or with a module?


texts:
Here is what we are doing:

We are working to build a new theme for the website we are working on.
We are using ThemeKey and Context to utilize the areas of the new given content types / drupal paths we are using for the new theme instead of Panels.
Panels previously owned the pages we are building on.

For Some Reason, sidebars/blocks (from the previous panel) is still printing to the $content tag for the new theme.

Any Ideas?  It's somewhat hard to describe the behavior over this platform, if you ask questions, I promise to answer them quickly until the problem is resolved...


texts: Using 'return' with an ajax callback renders an entire page before my content is loaded

texts:
I'm developing a module that uses Openlayers maps and Drupal Commerce. When you click on the map, you should see products that relate to those coordinates of where you click. I have this working perfectly.

I've got a 'foreach' inside of my function that creates each product row:

foreach($alldata as $data) {
    $content = '';
    $date = substr($data['_source']['ver_date'], -4);
    $content .= '
';

    $titleString = '';
    $titleString .= $data['_source']['longname'] . ' ';
    $trimmedTitle = strlen($titleString) > 80 ? substr($titleString,0,80)."..." : $titleString;
    $content .= '' . $trimmedTitle . '';

    $content .= '
';
    print $content;
}

This works exactly like it should and renders the rows of products exactly like I want.

The problem I am having is that there is an 'Add to Cart' button that was created within another function somewhere else in the site that I have to render in this foreach.

$arr = explode(".", $data['_source']['price']);
$inner_html = '$'.$arr[0].' Print';
$add_to_cart_btn = drupal_get_form('myModule_product_cart_button', $inner_html, (object)$data['_source']);
$content .= '
' . drupal_render($add_to_cart_btn) . '
';

The button loses it's Ajax properties when I use 'print $content'. So I changed it to 'return $content' and moved it outside the 'foreach'.

I get all of the content properly as well as a working ajax 'Add to Cart' button. However, I also get the entire page template rendered prior to all of my content that I'm returning.

<--- Content Rendered In Div via Ajax --->

Full Empty Page Template
---------------------------
Ajax content formatted properly and working properly

I've tried using ajax_render. I've tried using ajax_command_html. I've tried completely redoing my function and ajax to use drupal.behaviors. Nothing is working to remove that full page from rendering prior to my content. It only happens I when use 'return'. I've also tried adding drupal_page_footer().

Even when I have absolutely nothing in my foreach, if I use 'return $content', I get a full page rendered. And it's not the use of '$content'. I've changed that to other variable namespaces and it still renders an empty page template.

Here is my ajax call:

 $('.products').mousedown(function() {
    $.ajax({
      url: Drupal.settings.myModule.ajaxUrl,
      method: 'post',
      data: {
        longtitle : title,
        id : id
      },
      dataType: "text",
      success: function(data) {
        var markup = '';
        markup += data;

          $('.products-pane').html(markup);

      }
    });
  });

Anyone know what is causing this?


texts: Get role label instead of "database value"

texts:
I want to know how to show role label in twig view.

I have this

{% set roles = user.getroles(TRUE) %}
{{ dump(roles) }}

It's giving me my role, but instead of showing "Directeur (CR)" this is showing "directeur_cr_".

How can I display "Directeur (CR)" ?


texts: How to overcome error caused by non-existent service "entity.manager"?

texts:
I am running drush first time in my Drupal 9 project and getting the following error
 In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
  The service "sanitize.userfields.commands" has a dependency on a non-existent service "entity.manager".

Is there anything I have missed?
I was trying to list all available commands.
After @hurdi's comment I found  drush --version drush cr are  working.
Note: It is my first Drupal setup and I'm learning it.


texts: Best way to optimize for authenticated user performance?

texts:
The keyword here is authenticated!

Currently (as far as I know) the de-facto ways to optimize for anonymous access are through static page caches (varnish/squid/boost).

However, as far as I know this doesn't seem to do much good in a scenario where most of your users are authenticated.

Besides the obvious APC, Memcache and throwing money at hardware, what is the best way to performance tune a high-traffic site with mostly authenticated users?

For example: drupal.org, social networks, communities, etc.

I'm more interested in Drupal 6 at the moment so I guess MongoDB doens't apply for now...


texts: Unable to set #default_value for a date field

texts:
I have a form with a date field.

$form['filter_dates']['start_date'] = [
    '#type' => 'date',
    '#title' => $this->t('From'),
    '#description' => $this->t('Start event date'),
    '#default_value' => [
        'year' => 2015, 'month' => 05, 'day' => '09',
    ]
];

But when the form is displayed the date field doesn't contain the value "09.05.2015". The date field is empty.

Could you clarify me, how can I fill the date field with the value ?
I watched it as on my form as on the examle form from the Examples module.


texts: Organic Groups: Error, The website encountered an unexpected error.

texts:
I had OG working fine except I wasn't able to upload images to be displayed (but to still keep the File field for PDF uploads as private to just the group).

However I've gone through and removed the CKEditor module as people suggested to use WYSIWYG with CKEditor (js library) so I moved that.

Then I installed the IMCE - WYSIWYG bridge too and tried several things to get the images working.

They were working but I noticed PDFs were no longer private, now I seem to have narrowed it down to the OG field settings.

If I add the "Group Audience" field to the content type (which is set as OG group content), then I can no longer visit that page and get this error:

EntityMetadataWrapperException: Unknown data property og_group_ref. in EntityStructureWrapper->getPropertyInfo() (line 339 of sites/all/modules/entity/includes/entity.wrapper.inc).

As soon as I remove the Group Audience field, I can access the content type again (i.e. I can edit, add new etc. for this one content type). However I need the Group Audience field to keep the content secure/private.


texts: Hide 'previous' on first and 'next' on last image in views slideshow

texts:
I create slideshow using Views Slideshow module, controls are enabled (previous, next), I enable and 'End slideshow after last slide' in settings.

Now, how I can hide 'previous' text on first image in slide and 'next' text on the last image in slide?


texts:
I'm sure its a simple question but i cannot find any resource to the solution.

In Omega 4, i keep getting this message "The settings for this theme are currently served from a variable. You might want to export them to your .info file".

So how do i do that?


texts: List all fields with the feature they are defined in

texts:
I'm interested in generating a list of all fields with a column highlighting the feature that contains the field base setting and another column highlighting the field instance feature, (if the field is defined in a feature).

Something like this...

Field Name     |   Field Base Defined In  | Field Instance Defined In
field_subtitle |   mysite_shared_fields   | blog_story_feature
field_other    |   mysite_shared_fields   | blog_story_feature

Has anyone attempted this? Or can anyone suggest a solution.


texts: Trying to leverage drupal_add_html_head to add an ie10 class

texts:
Since IE10 does not understand conditional comments, I can't use the typical methods to single out that browser. However, I found a nice function that works well and if I add this to html.tpl.php in my theme:

<script>if (Function('/*@cc_on return document.documentMode===10@*/')()){
    document.documentElement.className+=' ie10';
  }
 </script>

... it works for IE10 and adds an HTML class of ie10.

But for best practices, I really want to use a preprocess function. So I looked at drupal_add_html_head and that seems to be the ticket. But when I formulate my code as such:

function MYTHEME_add_html_head($element, $inline_script) {

  $inline_script = <<<EOL
  <script>if (Function('/*@cc_on return document.documentMode===10@*/')()){
    document.documentElement.className+=' ie10';
  }
  </script>
EOL;
$element = array(
'#type' => 'markup',
'#markup' => $inline_script,
);
drupal_add_html_head($element, 'system_ie_browser');
}

... it does not work. There does not seem to be a lot of documentation around this and I could not really find anyone else doing exactly what I need so I'm a bit lost here. I replaced MYTHEME with the actual theme machine name and cleared cache too.

What I'm not sure about is if this part...

drupal_add_html_head($element, 'system_ie_browser');

... is significant in terms of Drupal understanding it and where to put it. I don't know if there are specific variables that go there. I just sort of made system_ie_browser up.


texts: Compare two same fields with time difference in Views, using node revisions

texts:
I'm trying to build a view containing two columns: first is the actual value of a (integer) field, second is the same field with its old value from two weeks before, using the revision. I suppose I would need a relationship for the second one but can't figure out how do to so.

The great Diff module help comparing one node at a time, but I would need to compare a list of nodes, reason why I want to do it in a view.

Any help would be more than welcome!


texts: Share one back office (database) over three drupal websites

texts: I'm wondering if there is a way to have one back office for three drupal websites with different domaine names, so I can share users over the three websites, I think I'm gonna have one database for all my drupal websites, but I'm not sure how I can achieve this using drupal.


texts: Do we need to update every release sequentially to get to the latest version?

texts:
Drupal releases a minor release approximately every 6 months, and a patch release every 1 month. Do we need to update to each one of them sequentially in order to get to the latest version? E.g, if I'm on Drupal 8.5.0, and the current Drupal version is 8.6.1, do I need to follow the order and update each release in the order 8.5.0 -> 8.5.1 -> 8.5.2 -> 8.5.3 -> 8.5.4 -> 8.5.6 -> 8.6.0 -> 8.6.1, or can I directly update to 8.6.1 from 8.5.0 by replacing the core files?

If we can update to 8.6.1 directly, how do we handle the case if a release like 8.5.4 requires changes to 'default.settings.php' but 8.6.1 doesn't require?


texts: How do you programmatically create a webform with a managed_file type?

texts:
I haven't been able to find a single example of how to create a webform with a managed_file type.

The webform initially had the type 'file', but needs to be changed to accept multiple attachments. When the type is changed to 'managed_file', the field for uploading attachments does not render.

Here is my code snippet for the attachment field:

7 => array(
    'name' => t('Attachment'),
    'form_key' => 'attachment',
    'type' => 'managed_file',
    'upload_location' => NULL,
    'pid' => 1,
    'weight' => 6,
    'value' => '',
    'required' => '0',
    'extra' => array(
      'directory' => 'story',
      'title_display' => 'before',
      'private' => 0,
      'wrapper_classes' => '',
      'css_classes' => '',
      'filtering' => array(
        'size' => '2 MB',
        'types' => array(
          'gif',
          'jpg',
          'jpeg',
          'png',
          'txt',
          'rtf',
          'html',
          'pdf',
          'doc',
          'docx',
          'ppt',
          'pptx',
          'xls',
          'xlsx',
          'zip',
        ),
        'addextensions' => '',
      ),
      'rename' => '',
      'scheme' => 'public',
      'progress_indicator' => 'throbber',
      'description' => '',
      'attributes' => array(),
      'analysis' => FALSE,
    ),
  ),
);

Thanks much!


texts: How do I load the node create or edit form?

texts:
To load the login form I am using the following code.

$form = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserLoginForm');

I would like to load the form to create or edit a node. How can I achieve this?


texts: Where should I put a modified version of l() function?

texts:
I want to customize l() function, which is part of Drupal 7 core and it is located in the common.inc file.

Where should I put such a function?

Modifying l() function or putting a new function in the common.inc would be considered hacking the core.


texts: How can I cascade field display formatters?

texts:
I need to display a thumbnail of my images and the count of its downloads below the thumbnail.

I am using these modules:

CCK
FileField
ImageField
ImageCache
DownloadCount

and I think I need something like cascading these two formatter:

Generic files with download count (comes from DownloadCount)
examination_question_image image linked to image (comes from imagecache where examination_question_image is my "Preset Name")

Is there any module or anything else for this?


texts: How can I specify inner elements template in custom login page?

texts:
I am new in Drupal 8. I want to create a new theme to according to my HTML. What is the best practice to integrating a custom build theme to drupal engine.

I have covered all sections in Drupal 8 theming tutorial. Now I need to integrate custom login page.

I have added the following hook inside mytheme.theme file

function wms_aupl_theme(&$existing, $type, $theme, $path) {
  $hooks = array();
  $hooks['user_login_form'] = array(
      'render element' => 'form',
      'template' => 'user-login-form',
  );
  return $hooks;
}

And Inserted my HTML in user-login-form.html.twig file as follows.

        <form{{ attributes.addClass('user-login') }}>

Auktionsplattform

                    Some dummy content

            {{ form.name['#title'] }}

                        {{ form.name. }}

                {{ form.pass }}
                Passwort vergessen

            {{ form.form_build_id }}
            {{ form.form_id }}

                    {{ form.actions }}

                    Noch kein Konto? Hier registrieren

        </form>

Now i need to specify inner element's template. How can I specify inner elements template?

Is there any better way to do this?


texts: Drupal 7 Organic Groups, Drupal Commerce and Paypal

texts:
I have a Drupal 7 site, with OG and commerce installed.  I have an og content type populated with content.  Everything is working as expected.  I found this link on Drupalcommerce:  https://drupalcommerce.org/blog/10809/selling-organic-groups-using-drupal-commerce and it is very close to what I'm after.  However, I don't want to charge the users for access to the group. I want to charge per group.  Just like meetup.com does.

In short, I would like for a user to:

Enter a group name Username and email
They are taken to Paypal to complete transaction
Paypal signals the transaction is complete
The group and user are created.

Any tutorial or guidance is appreciated.
Many thanks
Chris


texts: How do you change what a function in a core module does?

texts:
I am trying to change certain Drupal behavior. I have traced this behavior back to a function in RDF core module, and would like to change what it does. The function in question is rdf_preprocess_node().

Getting what I want would seem as simple as removing one or two blocks of code from this function. So that's exactly what I tried doing: I copied the function into my theme's template.php, made the changes, renamed the function from rdf_preprocess_node to THEMENAME_rdf_preprocess_node. This did not work, Devel Themer did not list my THEMENAME_rdf_preprocess_node among the preprocess functions used.

I do not understand why this didn't work. Only other option that I know is to try and dig through what the function affected and undo it, which sounds horrible.

What's a practical way to change what a function from another module does?


texts: how to change widget type of title field in content type Drupal 7

texts: I am trying to change the widget type for title field in content type (currently it's a text field as default). Now I want to change to node reference.


texts:
For some reason I cannot find the settings to turn on the delay for my superfish menu. I was able to get to it a couple of weeks, but not any more.

All I see when I go to /admin/config/user-interface/superfish is the ability to change the number of blocks and paths to superfish library.

How do I get to the settings where I can turn on delay?


texts: How can I use Display Suite with a Drupal Commerce view?

texts:
I am new to Display Suite and want to use it with the Drupal Commerce checkout forms. In particular for the review stage, which is made from a view.

I want to display the order summary in the left column and the customer profile address details in the right column.

I can see how Display Suite is used for regular nodes, but can not find any information about how it can be used for views fields. Is this even possible?


texts:
I use this to alter field labels:

function ninesixty_form_user_login_alter(&$form, &$form_state) {
    $form['name']['#title'] = t('Name');
}

But how do I change the title of the button? The button is <button> not <input> and it's for node creation form. Form id is titles-node-form.


texts: How can I show a message to visitors of a blocked user account page in Panels?

texts:
When a user account is blocked, the user profile can no longer be viewed.  This makes sense, but is it possible to use Panels to override the user profile display to show a custom variant that has a message like "This user has closed his/her account"?

I looked through the available Selection rules, but the only one that seemed like it might work is User has permission (I tried one of the "edit content" permissions since I don't think that blocked users have permission to edit content).  However, setting "not having edit permission" as a selection rule did not cause my custom variant to be displayed.

Again, what I want to do is show a message on the user profile page ("This user closed his/her account") instead of the default behavior, which is giving me a "too many redirects" error.


texts: How to remove some comments from a node?

texts: I created a new table in the database to associate comments to the node version they were submitted against. Now when the node renders, I only want to display comments that are associated with the specific node vid. I thought about querying the db in hook_node_view to remove the comments that don't apply, but ideally only comments associated with the vid are added to the node in the first place. Is there a better way to implement this? Can I get at the node right before the comments are added to it?


texts: How to prevent a PDO exception when using Rules to Set a data value after saving new content?

texts:
I need to write a rule that edits some elements of the node, as soon as it is created. Unfortunately Drupal doesn’t like that and crashes whenever you try to save the node within a rule that was triggered by "After saving new content".

Event: After saving new content

Conditions: ...

Actions: Set a data value, with
Parameter: Data: [node:field-workflow...], Value: 1

The above results in:

  PDOException: SQLSTATE[23000]: Integrity constraint violation:

So far I managed to walk-around that with hook_forms, changing the workflow in my portal (so I never have to edit the node just after it is created)

Things get really interesting when I try to use "Execute custom PHP code" action which will change the node value I want:

node_save will result in drupal crushing
db_update - seems to work most of the time...
db_insert - sometimes works (works for superuser only)

Unfortunately all my hacks don't work for all my problems. How else I can address this situation?


texts: Is check_plain() enough for re-displaying the text entered by users in the browser, or should I still filter with filter_xss()?


texts: How to use multiple reverse relationships from different content types in a single View Drupal 7?

texts:
i have three content types

1- News

2- Articles

3- Press Releases

On every content type we have a custom field called 'industry'.

so when we create a news (or article or press release) we fill the industry field 'construction medical energy etc etc' (Means on which page[of content type industry] it should be display)

i want to create a view where i want to show all three content types "news ,articles, press releases" which have the field 'construction' in it.

Step by step Snap shots are attached for my views and content types.

adding news: http://prntscr.com/b940qh
my view screen shot: http://prntscr.com/b943oi
Want Result like : http://prntscr.com/b948qv


texts: How can I show/hide a block on specific taxonomy URLs depending on term depth?

texts:
I need to show blocks on different url's.

Block1
Should be displayed on:
branches/taxonomytermlevel1
But not on
branches/taxonomytermlevel1/taxonomytermlevel2

Block2
Should be displayed on
branches/taxonomytermlevel1/taxonomytermlevel2
But not on
branches/taxonomytermlevel1

The terms
/taxonomytermlevel1/taxonomytermlevel2 are variables (elements in some taxonomy list)

What is the most easiest way to do this? I think a php script in the block display visibility setting would be the trick and so I tried some code there but I did not succeed.

Some code I have now is e.g.:

<?php
if (empty(arg(3))) {
  return TRUE;
}else {
  return FALSE;
}
?>

Any suggestions?


texts: Referenced entity is output each time instead of once

texts:
I use out-of-the-box articles content type to which a I added en entity reference field so I can assign multiple users to that article. I used this reference in order to be able to display multiple authors for that article.

The end goal is, that when the detailpage of an article is displayed, to have a block listing the assigned users and per user listing the nodetitles that reference this users (so-called authors). Basically, trying to mimic the out-of-the-box author-functionality using entityreference. In views' preview function, I would then add a nid that uses the conextual fileter.

The output that I want then would look as follows:

From John Doe:
Lorem Ipsum
Ipsum Lorem
Irem Lopsum

From Plain Jane:
Irem Lopsum
Ipsum Lorem

I almost managed to configure this with views

Added a contextual filter that pulls in the nid so I can filter the assigned users based on that nid.
Configured a relationship for the users that are referenced by the nid that is displayed. I use this in my first field to display the assigned users. This works fine
Configured a second relationship for the nodes referencing my users. Also pulled in this relationship when making my second field that is content:title.

What I get instead though and what I don't want is the following:

From John Doe:
Lorem Ipsum
From John Doe:
Ipsum Lorem
From John Doe:
Irem Lopsum

From Plain Jane:
Irem Lopsum
From Plain Jane:
Ipsum Lorem

I read this drupal answer, where someone wants to display an amount of referenced entities. This seems close to my issue, but I have the feeling that my problem isn't really one with aggregation or grouping. Still not sure of course, but I just can't seem to understand how it would fit my case. Semantically though, the word grouping obviously suggests I'm on the right track. Technically OTOH, it's not quite making sense to me, since it seems to group data rather than markup the way I want it to.

I also watched both the NodeOne video's 1 and 2 mentioned in drupal answer stated above. Other than fiddling with aggregation settings, I also deleted the default sort criteria as suggested. Didn't help.


texts: How can i integrate java application with drupal?

texts:
I a new to Drupal. As per my knowledge drupal is based on PHP. How can I get the contents from drupal and use in my java web application?

Is there any way to get the contents from drupal schema which I need complete information of drupal table structure, how contents get saved in tables?


texts: How to change the language of a node and all its fields and all related data?

texts:
On my multilingual site, I have a content type that is going to be user created. I want to keep it language neutral ('und').

But there already are a couple thousand nodes of that content type and they have English set as their language.

To make them language neutral, I want to write one time update function (hook_update_N) to change the language of the nodes and all their fields from 'en' to 'und'.

I am doing this by making changes directly to database (using db_update) to the language column of node & related field tables. But I am afraid that I may miss something. Can I do this some other way to not miss anything.

I read somewhere that I can user hook_node_presave & node_save to do this but I am not sure how.

Also, how can I make any future nodes' language to be set default as 'und'?


texts: How to change the directory of file_create_url to default for a custom domain

texts:
Suppose, we have a file: /sites/default/files/picture.jpg

Drupal is installed into a subdirectory: /drupal. There are 2 domains, attached to the site:

exchange
exchange-test (uses different DB)

 | domain        | settings.php path     |
 |---------------+-----------------------+
 | exchange      | /sites/default/       |
 | exchange-test | /sites/exchange-test/ |

When we call

print file_create_url('public://picture.jpg');

we get:

| site          | result                                        |
|---------------+-----------------------------------------------|
| exchange      | /drupal/sites/default/files/picture.jpg       |
| exchange-test | /drupal/sites/exchange-test/files/picture.jpg |

But the file is stored in default directory even for exchange-test domain.

As far as I could find, the path is being generated, using function conf_path. It scans the config directory to find a subdir with current domain name:

 $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
  for ($i = count($uri) - 1; $i > 0; $i--) {
    for ($j = count($server); $j > 0; $j--) {
      $dir = implode('.', array_slice($server, -$j)) .
             implode('.', array_slice($uri, 0, $i));
      if (isset($sites[$dir]) &&
          file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
            $dir = $sites[$dir];
      }
      if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') ||
         (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
            $conf = "$confdir/$dir";
            return $conf;
      }
    }
  }

If found, it uses this directory as files path.

So, one way is to temporarily change $_SERVER['HTTP_HOST']:

$_SERVER['HTTP_HOST'] = 'exchange';
print file_create_url('public://picture.jpg');
$_SERVER['HTTP_HOST'] = 'exchange-test';

Will give the correct result. But this trick seems clumsy to me. Is there any way to get the default directory without such hacks?


texts: There is data for the field - On uninstalling module

texts:
Given I have a module that defines a new field on an entity. How can I delete that data on uninstalling? There is a requirement:

  There is data for the field X on entity type Y

which means I cannot delete the data on the hook_uninstall since it cannot be called.


texts:
In admin/structure/menu I created a menu
In admin/structure/block I created a 'menu block' with above menu

With below code I am able to render the menu in page--front.tpl.php

<?php
 $block = module_invoke('menu_block', 'block_view', '3');
 print render($block['content']);
?>

But how do I render the Menu block Title?


texts: Possible to alter user account status options on user_register_form?

texts:
I'm looking to alter user_registration behavior to allow certain users to reopen their closed or blocked accounts but not users who have been explicitly banned. As such, I'm looking to modify the current form element for ['account']['status'] from just allowing 'Blocked' and 'Active' to something like this

  $form['account']['status']['#options'] = array(t('Blocked'),
  t('Active'), t('Banned/Dead to Me'));

This is an easy form_alter hook to execute and Drupal will add the new value ('2') in the users table but it doesn't know what to do with it in other functions, ex. on the admin/people page, it doesn't recognize the new value:

  Notice: Undefined index: 2 in user_admin_account() (line 226 of
  /public/modules/user/user.admin.inc).

Is there another way to customize the user status options or is this a protected core value? Are there already modules that add new user status options that I could look at as a model?


texts: REST Export Views and images alternative text

texts:
I have a simple REST export View. The View format is set to "Show: Entity".

The content type I am exporting contains a standard image field. My image field settings is set to "Enable Alt field" and "Alt field is required".

Therefore all my nodes that have an image, have an image alternate text (Alt).

In the JSON that my view outputs, there is nowhere that I can find the value of the image alternate text.

For each image, I get the filesize, the filename, the filemime, the uri, etc. etc. but no alt text.

Any idea why? And how could I retrieve it? (other than by replacing the image alt text by a separate field...)


texts: This site comes with a nice drag and drop builder for webform. What modules are required to create a builder like this?


texts:
I have a form that includes a managed_file field as well as a data popup and select field.  When the user selects a date, an ajax call is made to populate the select field.  However, I noticed that each time the ajax call is made, the file is uploaded, causing multiple copies of the file to to exist (each subsequent file having a number appended to the .  If the user selects another date, the file is uploaded again. How do I prevent the file from being uploaded multiple times during the ajax call?

Here is my form code

function _timesdb_import_form($form,&$form_state) {

  $form['file_fid'] = array(
    '#type' => 'managed_file',
    '#title' => 'Import File',
    '#size' => 100,
    '#description' => 'Select an import file.',
      '#upload_location' => 'private://filelocation/',
      '#required' => true,
      '#default_value' => variable_get('file_fid',''),
    );
    $form['date'] = array(
      '#type' => 'date_popup',
      '#date_format' => 'm/d/Y',
      '#title' => 'Start Date',
      '#description' => 'Enter the start date of the meet. After changing the date, select the meet below',
      '#ajax' => array(
      'event' => 'change',
      'callback' => '_timesdb_import_meets_ajax',
      'wrapper' => 'timesdb-import-meets',
    ),
  );

  $meet_options = isset($form_state['values']['date']) ? _timesdb_import_get_meets($form_state['values']['date']) : array();
  $form['meet'] = array(
    '#type' => 'select',
    '#title' => 'Select meet',
    '#options' => $meet_options,
    '#prefix' => '
',
    '#suffix' => '
',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#default_value' => 'Submit'
  );
  return $form;
}

The ajax callback looks like this

function _timesdb_import_meets_ajax($form,&$form_state) {
  return $form['meet'];
}


texts: How do I make the custom module "Configure" option appear on the module list?

texts:
I have written a simple module that implements hook_menu() (the added path is admin/settings/mymodule").

On the admin/modules page which lists all the present modules, there is no "Configure" link for my module. How do I implement it so that the link to "admin/settings/mymodule" is visible on the modules page?


texts: Problem rendering paragraphs field - advanced but still not working

texts:
I am working on a site with one special page layout (lets call it originally "two columns"), which has basically two columns: The left one showing page contents and the right one an unlimited number of paragraphs.

There is still one problem:

1) The twig tries to show also the paragraphs in the end of left column not following the without-filter. If I show the field title (content type Manage display) it shows the title in the bottom of the left column but no other output is generated of the field_aside paragraphs

2) I can't get the right column to show anything from the field_aside, whatever I try.

The crucial code comes here (the best idea what to do so far, tried a multitude of alternatives with zero results)

    {{ content.body }}

    Aside...
    {{ bamboo_render_field('field_aside', 'node') }}

The page is using a Bulma based theme but I'd reckon it has nothing to do with the problem.

I have Bamboo Twig and Bamboo Twig Loaders enabled.

The field_aside should render the corresponding paragraph texts.
wbr

hank


texts: Keep submenu expanded when parent or children are active

texts:
I have a two-tiered menu system using the Nice menus module, which I've adapted to run horizontally with the children beneath the top level, as in the following menu.

  Home - About - Adopt an animal - Events - Get Involved - Contact

  Cats - Dogs - Small Animals - Birds

At the moment, the second tier is showing only on hover of the parent. After clicking through or landing on a page I need the children to be expanded when their parent or siblings are active and I'd like the parent to be highlighted as active in this case too - so in this example if I'm on Adopt an animal page or dogs / small animals / birds  then I need that expanded.

I'm not sure where to even start on this, I don't really want to hack it by duplicating false second tier menus and using context or block to display them on certain pages because I need to be able to hand over the menu administration so the integrity is important. Thanks for any suggestions.


texts:
I'm using the Configuration Inspector module module, and I'm finding a missing schema error.

The configuration is for block.block.pminbox.settings.thread_count

The block itself is a plugin, created in my module. I've tried:

Adding the settings to the block annonation
Creating block.block.pminbox and adding settings as a mapping with thread_count as a property of that mapping
Creating block.block.pminbox.settings and adding thread_count in there
Adding the config to mymodule.schema.yml

Here is where I am at as of now.
Submit handler for class extending BlockBase:

  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['thread_count'] = (int) $form_state->getValue('thread_count');
  }

mymodule.schema.yml:

block.settings.pminbox:
  type: block_settings
  label: 'Private message inbox block settings'
  mapping:
    thread_count:
      type: integer
      label: 'Thread count'

The rest of the schema in this file is being picked up, however, I'm still getting a 'schema undefined' error from the configuration inspector for this block.


texts: What happens when an email from webform fails to deliver?

texts: If webform attempts to send an email but cannot connect to the smtp server, what happens to the email? Does it get dropped on the floor? Does it throw an error in a log? Does it try to resend later? Does it mark it somewhere as unsent?


texts:
I use Search API, Search API Database and FacetAPIto create custom search. And there are mistakes in facets when it displays field with hyphens. For example, there is a text field "city" with value of "Rostov-na-Donu" (the name of the city in Russia). Facets show me three values: Rostov, na, Donu. But I want only one value for this field and it should be entire field content.

Please help.


texts: How to set Form API date_select option values

texts:
Creating a date_select field in a custom form, like this:

$date_format = "Y-m-d";
$form['birth_date'] = array(
    '#type' => 'date_select',
    '#title' => t('Date of birth'),
    '#default_value' => NULL,
    '#date_type' => DATE_FORMAT_UNIX,
    '#date_timezone' => date_default_timezone(),
    '#date_format' => $date_format,
    '#date_increment' => 1,
    '#date_year_range' => 'now:1910',
    '#date_label_position' => 'within',
    '#required' => TRUE,
);

The  element it generates for the year dropdown is like this

<select>
  <option value="0">-Year</option>
  <option value="1">2017</option>
  <option value="2">2016</option>
  <option value="3">2015</option>
   .
   .
   .
  <option value="108">1910</option>
</select>

The year value returned in $form_state['values'] is the value of the option, e.g. if 2017 is chosen the value returned is 1. Is it possible to somehow set the option values like this instead

<option value="2016">2016</option>

so that the actual year will be returned?


texts: How to display calculated values in Drupal 8 views?

texts: Lets say I have an account field called euro-budget, and I have a content type exchange rate including the field usd-value" which import the USD exchange rate every 2 hours. In the view which displays all users including the field euro-budget. I want to have a calculated field which multiplies the field euro-budget with the latest usd-value field. What is the easiest way to do this? I already tried Views PHP but it is somehow not compatible with the latest Drupal 8 version.


texts: drupal_render($node_view); is not working

texts:
Node page is not loading once I add below code

 drupal_render($node_view);

I was referring https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_view/7
and added below code in my node--type.tpl.php

<?php
  $node = node_load($nid);
  $node_view = node_view($node);
  $rendered_node = drupal_render($node_view);
  echo $rendered_node;
?>


texts:
I currently have a Drupal 7 Multi-Site. In my sites folder, the domains are like this:

winatlife.guide
journal.winatlife.guide
store.winatlife.guide

I need to change the domains to this:

blog.blessingsjournal.com
journal.blessingsjournal.com
store.blessingsjournal.com

In addition, my root drupal folder is changing from win-at-life to blessingsjournal.

I have made all these changes. When I visit any of domains, I get the following error message:

Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

What could be chasing this? I haven't changed any of the permissions on the Drupal install.

Steps I have tried

1) Database Update

This StackOverflower answer says that the domain is hardcoded in the database and it provides a query to fix it. I have run the query, but it does't seem to have done anything.
It was written in 2010, so maybe it's for Drupal 6?

2) Make a sites.php file

According to this Drupal Groups thread, in Drupal 7 multisites, you need to put a file called sites.php in the root sites directory. (In that directory there is an example.sites.php which can be used as a template).

I made a sites.php file and used the new domains but it had no effect. (Nb I did not need to use such a file before the domain change)

3) Checking .htaccess

My .htaccess is set as follows:

  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
   RewriteBase /


texts: Cant display dropdown values on drupal commerce review page

texts:
I have a some dropdown fields on on my commerce checkout page where the key is different than the value. I need this to be the case, because at checkout completion, I am submitting the values to an external database, and it expects the key value, not the display value.

However, I've found that the review page is listing the values (which is an uninteligble code and therefore useless to the user). I have not found a way to change this. If you inspect the array building the review page, it contains an array element 'data' which stores all the markup, and I see no way of modifying the display.

How can I display the dropdown keys on the review page?

EDIT:
To perhaps make this a little eaiser: by backtracing, I found that this function

customer_profile_type_ui/includes/customer_profile_type_ui.checkout_pane.inc:74:function customer_profile_type_ui_pane_review($form, $form_state, $checkout_pane, &$order) {

was calling this one

commerce/modules/customer/includes/commerce_customer.checkout_pane.inc:315:function commerce_customer_profile_pane_review($form, $form_state, $checkout_pane, $order) {

If you examine the code there, you will see that the review pane is being populated directly from the profile object, and the profile object is only storing the values (which makes sense). So, is there any way for me to obtain the keys?


texts: How do I make a custom block that has an image background with hotspots?

texts: I am working on making a custom module with a block that contains a floor plan.  It will be an office, when you hover over employees desks it will have a bubble appear showing that employees project status and other information.  All instructions I can find for setting the image in the block uses css.  Is this how I need to do it? Will i be able to set regions for mouse over this way?


texts: How do you update a Live drupal server without overwriting the contents?

texts:
I have a site that is live and people are actively putting in content.  However, I have had to make some changes in the development environment, which has taken me a couple of weeks to do. The changes required new modules to be installed and old ones to be removed, which of course changed the database contents and structure.

My question is how do I upload this site back to the live environment and update the database without overwriting the new content new users that have been added over the last two weeks?


texts: How to make sass/scss module work with omega theme?

texts: When installing sass/scss module, and followed readme instructions... then nothing happens. Is there any clue for this ?


texts: In Ubercart Which Hook is reponsible for adding product to the cart page(On clicking add-cart-button)?

texts:
In ubercart,While buyer sees a product and clicks on add-to-cart button for buying that product, i want to know which action is responsible for that product being added in to the cart?

I want to edit the sell price, so that only this question.
Already tried this hook, but it was not printing anything,

    mymodulename_uc_add_to_cart($nid, $qty, $data) {
    print "<pre>";print_r($data);print "</pre>";exit;

    if ($qty > 1) {
        $result[] = array(
                'success' => FALSE,
                'message' => t('Sorry, you can only add one of those at a time.'),
        );
    }
    return $result;
}

Which of these hooks

hook_uc_add_to_cart
hook_uc_add_to_cart_data
hook_uc_cart_checkout_start
hook_uc_cart_display
hook_uc_cart_item_delete
hook_uc_cart_item_insert
hook_uc_cart_item_presave
hook_uc_cart_item_update
hook_uc_cart_pane
hook_uc_cart_pane_alter
hook_uc_checkout_complete
hook_uc_checkout_pane
hook_uc_checkout_pane_alter
hook_uc_update_cart_item
uc_checkout_pane_callback

is responsible for adding quantity and price to cart in the cart page.Or is there any other hook which is doing it ?

Any ideas? Thanks in advance


texts: How to add integer field to content type?

texts:
I am trying to add  year field to content type. I selected integer as field type, then i see text field as widget. How can I set to 4 digits max and allows only numbers only?

Thanks,
D


texts: Need to display Views block in between two fields of a node

texts: I have dynamic view block that i need to display between "body" and "last updated" fields of a Basic page node. (i.e. "last updated" field has to be at the bottom of a page).


texts: How can I set values in the $conf array using the admin interface?

texts:
I am using the Journal  module and in order to limit the forms its text box appears on the form ids have to go into a $conf variable. The docs say it has to go into settings.php but I don't watch that.

$conf['journal_form_ids'] = array(
    'fivestar_custom_widget' => 0,
    'guestbook_form_entry_form' => 0,
    'imagefield_js' => 0,
    'img_assist_header_form' => 0,
    'img_assist_properties_form' => 0,
    'link_widget_js' => 0,
    ...
);

Is there a module that can accomplish this from the admin interface?
Can it be done through some kind of execute PHP form like with devel?

It has to be done from the admin


texts: How can I float a specific field to the right of another field

texts:
For example, I have one field in my content type that is a boolean value of "Is this employee certified" next to this field I'd like a Pop-up Date that shows the expiration field. I've created both fields for my content type but I have not seen anything in the CSS that allows my to float or align fields. Any help would be greatly appreciated.

Can I do this with Views? Or with CSS? Thank you


texts:
In order to display the date information in French, I have modified the node.tpl.php file as follows.

 print t('publi&eacute; le !datetime',
      array('!datetime' => format_date($variables['node']->created, $type='medium', $format = 'D j F Y', $timezone = NULL, $langcode = 'fr'))
 );

The week day, and the month are still displayed in English!


texts: Panels view settings - how to preprocess the 'more' link

texts: I have block views added to a panel, and the panel is set to display the 'more' link. How can I change the text for this link?


texts: Commerce Checkout Alter Email Field Value

texts:
When anonymous user is on checkout page using DRUPAL commerce, I want to autofil email field in Account Information section on checkout page.

I tried using hook_form_alter to give it a default value, but I guess, since this is a multi-step form, so it ignores when goes to REVIEW pane.

if ($form_id == 'commerce_checkout_form_checkout') {
  $buyers_email_retrieve = 'myemail@email.com';
  $form['account']['login']['mail']['#default_value'] = $buyers_email_retrieve;
  $form['account']['login']['mail']['#attributes']['disabled'] = TRUE;
  $form['account']['login']['mail']['#required'] = FALSE;
}

After giving it a default value, it still throws a validation error, so required property is set to FALSE.


texts: Programmatically insert field collection of Phone fields

texts:
I have a profile2 profile type. In profile type i have created the collection for storing the information of form fields.

I have used the phone module to create the phone number fields.
This collection contains the two phone number fields, one for office and one for mobile.

So my scenario is give below

--Profile type

--- Field collection to store the phone numbers

---- Two fields to store  phone numbers
    1. field_office_phone
    2. field_office_mobile

Now i want to save the data of the field programmatically.
I have used below snippet from here to create and save the field collection programmatically.
In the given below code company is my profile2 profile bundle.

module_load_include('inc', 'field_collection', 'field_collection.pages');
  // Load the profile we're adding the field to
  $profile_entity = profile2_load_by_user($account, 'company');

  // Define the values of the new field
  $values = array();
  $values['field_name'] = 'field_contact_number'; // field collection name
  $values['field_office_phone'][LANGUAGE_NONE][0]['#value']['number'] = 1234;
  $values['field_office_mobile'][LANGUAGE_NONE][0]['#value']['number'] = 12374;

  // Create the field collection entry and associate it with the profile
  $field_entity = entity_create('field_collection_item', $values);
  $field_entity->setHostEntity('profile2', $profile_entity);
  $field_entity->save();

The above code snippet only creates field but it is not storign the values in the field.
I am not getting the reason why it is not setting the values.


texts:
I'm looking for the features of the editable views module without having to use a table (In Drupal 7).

I have a view that I use as an input form. I'm using the "editable views" module to expose those fields as editable. However, I would like to customize this beyond what a Table will provide. There's some CSS trickery I can do (e.g. moving cells around with CSS), but that seems very hackish. Are there any modules/methods out there to do what I'm trying to do?

(example)

I have...

 | Title | Description | Author | Feedback (Editable) | Rating (Editable)

I want...

 Title, Author
 Description
 Feedback (Editable) | Rating (Editable)

Thanks


texts: Can't import from XML using Feeds importer and XPath parser

texts:
I'm trying to import book objects from the XML file you can see XML file Here. I will tell step by step what I did to achieve this, so it would be easier to help me.

Created a Book content type with all the corresponding fields from the XML file
Installed Feeds importer and XPath parser modules with their dependant modules
Created a Feed importer called bookImport
In the Basic settings I attached it to Book content type
The fetcher is a default one - HTTP
For parser I chose XPath XML parser
Processor is Node. As I want to create new Nodes for every single book
In the Node processor settings I chose Book bundle and everything else is left as it was by default.
In the mapping I mapped all the xpathparser:* source values to target ones from Book content type.

When trying to import, in the XPath Parser Settings for context I put book and leave everything (all the other book fields empty), I turn on my error messages and after clicking Import I get these two lines:

context :
There are no new nodes.

I've been trying to solve this for 2 days now without any luck, any help would be highly appreciated and I hope my post is informative enough, if there is something missing, please let me know and I will update!


texts: Drupal 7 Is the a way to programmatically know the Fields in a Content Type?

texts:
In Drupal 7, i need to Programmatically create the nodes, by using:

$node = new stdClass();
$node->type = "movie";

After, just this codes above, and lets assume i don't know what are the fields for it.

How can i get to know the fields and that field's structure for this Content Type?
(or) Can i echo out the fields inside a Content Type and its relations ?


texts: Why does pagination create duplicates in Google's results?

texts:
I created multiple views to display different types of nodes on my site. On each of these views, I added a pagination, which creates duplicates in Google's results. Why?

I think this is bad for the SEO of my site. How can I avoid this?


texts: Unset terms that show in taxonomy autocomplete

texts:
I would like to unset terms that show up in taxonomy autocomplete.

For example if TID 1 2 3 4, are in the taxonomy I would only like 1 2 and 3 to show in the dropdown for autocomplete.


texts: How to allow registered users to enable / disable notifications for event nodes?

texts:
I have an event node type. The site needs to allow registered users to enable or disable notifications for this event. So on the event page (I have several views, etc) I would like to have a button is seen by registered users.  It would be either show "Enable notifications" or "Disable notifications" based on its current value.

Ideally this would somehow associate the user and to the event (relation?) so that I can query db for all users who have enabled notifications for this event.

Any help or ideas on how to do this?


texts: How to create Select list on Entity forms with changeable list of key values?

texts:
I would like to create a field for my Entityform same as 'Select list' with ability to change its values after the data is submitted.

Currently when I am trying to change the default values of 'Select list' it gives me the error:

  Allowed values list: some values are being removed while currently in use.

or:

  There is data for this field in the database. The field settings can no longer be changed.

I believe this behaviour should be different than for Content type, as when using Entityform I don't care for already submitted data (as it's something that suppose to be submitted only once)?

Question

How do I create a Select list widgets on Entity forms where I am able to change its key values once the data has been submitted?

How do I fix or workaround that Drupal limitation, or I should use a different solution/module instead or write my own?

Example scenario

So for example I want to create a Select list widget (e.g. contact_by field) appearing on Entity form which has the following values:

by_phone|By Phone
by_email|By Email
ops_typo|By Post (fixme: correct typo)
by_fax|By Fax (fixme: remove me)

So the critical scenario would be a strong need of changing these values such as typo (correcting ops_typo) or changes in business requirement how these form works (e.g. I want to remove by_fax appearing on the submission forms for new forms), however it is currently not possible by using a standard Select list widget, because it has already some existing data associated with that value

Reproducible steps

Launch Drupal sandbox.
As admin, add a new entityform type (Admin/Structure/Entityform Types/Add) for auth users: Test
Add new required field Contact By of List (text) type as Select list widget pasting above values.
Create two entity forms (Admin/Structure/Entityform Types/Submit Link or at /eform/submit/test), one with By Post, another with By Fax values.
Now go to Manage fields of that Entityform, in 'edit field' or 'field settings' try removing/changing the last two values (the key part, not label).

Data storage

As per comment concern, the change of value won't corrupt any existing data (despite of the warning), because the value in stored is database in the text format anyway, for example:

INSERT INTO `field_data_field_title` VALUES ('entityform','test_title',0,207,207,'und',0,'Foo');
INSERT INTO `field_revision_field_title` VALUES ('entityform','test_title',0,207,207,'und',0,'Foo');

which has the references to the right entityform:

INSERT INTO `entityform` VALUES (208, 'test_title', '', 1447192797, 1447192797, X'733A303A22223B', 1, 0, NULL);

So when viewing the entity form (e.g. /entityform/208) is just showing plain text. I don't need to edit that data, as it's just one-off form submission.


texts: How would I wrap (or hard-code) HTML into a block title?

texts:
So I see this in the block.tpl.php:

/**
* @file
* Default theme implementation to display a block.
*
* Available variables:
* - $block->subject: Block title.
* - $content: Block content.
* - $block->module: Module that generated the block.
* - $block->delta: An ID for the block, unique within each module.
* - $block->region: The block region embedding the current block.
* - $classes: String of classes that can be used to style contextually through
*   CSS. It can be manipulated through the variable $classes_array from
*   preprocess functions. The default values can be one or more of the
*   following:
*   - block: The current template type, i.e., "theming hook".
*   - block-[module]: The module generating the block. For example, the user
*     module is responsible for handling the default user navigation block. In
*     that case the class would be 'block-user'.
* - $title_prefix (array): An array containing additional output populated by
*   modules, intended to be displayed in front of the main title tag that
*   appears in the template.
* - $title_suffix (array): An array containing additional output populated by
*   modules, intended to be displayed after the main title tag that appears in
*   the template.
*

I'm trying to set the $title_prefix & $title_suffix in my hook_block_view without much luck...

Here is the working version of what I have:

/**
* Implements hook_block_view().
*/
function activities_block_view($delta = '') {
 switch ($delta) {
   case 'find_activities_small':
     $block['subject'] = t('Find Activities');
     $block['content'] = drupal_get_form('find_activities_form');
     return $block;
     break;
 }
}


texts: Auto Increment - Order/user numbers not changing

texts:
I've executed the following via phpmyAdmin but nether the order nor user numbers change.

ALTER TABLE 'users' AUTO_INCREMENT = 1025;
ALTER TABLE 'commerce_order' AUTO_INCREMENT = 1025;

I checked inside 'commerce_order' and the AUTO INCREMENT is set to: 1025(order numbers should change).
When i check inside the 'users' table, AUTO INCREMENT is NOT available(why?).

I've cleared the cache.
Shouldn't this be working?
Drupal7

Thank you for your help!


texts:
I have a custom callback function that queries data from a custom table.

The trimmed version of code that I have been writing looks as below,

function cb_user_cashback_orders($account) {
  $sql = 'SOME SQL QUERY';
  $results = db_query($sql, array(':uid' => $account->uid));
  //date, Merchant name, commission, status
  $header = array(t('Date'), t('Merchant Name'), t('Commission'), t('Status'));
  $rows = array();
  foreach ($results as $result) {
    $rows[] = array(
      format_date($result->timestamp),
      $result->status ? l($result->title, "node/{$result->merchant_nid}") : $result->title,
      $result->commission,
      $result->status,
    );
  }
  pager_default_initialize(count($rows), 10, 0); // Pager doesn't appear without this call
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('You have not made any purchase yet.'),
    'attributes' => array('class' => array('cb-user-orders')),
    )
  );
  $output .= theme('pager'); // as a replacement for pager_query() in D6.
  return $output;
}

I'm trying to figure out how I could get the pager work as expected.

With the code above I'm able to get the pager links (first, next, last, etc.) however the table always show the same set of items (infact all items) irrespective of pager argument (?page=1,2 OR N).

Would like to hear some input to fix this. Is theme('pager') designed to work only with dynamic query?


texts: Programmatically created list_boolean checkbox field value won't get saved

texts:
I've added a lot of fields and field instances via a custom module to some prepared content types. field_create_field() and field_create_instance() work like a charm, not a single error. Every field then works as expected, EXCEPT for the checkbox field.

It appears at the right place, has the right label, BUT when it comes to node saving the checked checkbox simply won't save. Next time I edit the node it's unchecked again, no value got written to the database. What do I miss here?

$field = array(
  'field' => array(
    'field_name'  => 'MYFIELD',
    'label'       => 'Set as default',
    'type'        => 'list_boolean',
  ),
  'instance' => array(
    'field_name'  => 'MYFIELD',
    'entity_type' => 'node',
    'bundle'      => 'MYBUNDLE',
    'label'       => 'Set as default',
    'widget'      => array(
      'type'      => 'options_onoff',
      'settings'  => array(
        'display_label' => TRUE,
      ),
    ),
    'display'     => array(
      'default'   => array(
        'label'   => 'hidden',
        'type'    => 'hidden',
      ),
    ),
  ),
);

field_create_field($field['field']);
field_create_instance($field['instance']);


texts: User Specific Pages -but only editable by admin?

texts:
I couldn't figure out how to directly address my situation.

I've created a website and I would like to be able to create user accounts for my clients from which when they log in the main menu will have each users specific page. In that user specific page I'd like to have a user specific menu page/(index) to which other pages are linked, to be able to display another website/(iframe), (such as specific jobs for that particular client). I'll need to impliment this between now and a week or two.

I've looked at me aliases, couldn't figure it out. I currently have Access Control installed but that will only allow me to restrict pages based on authenticated or anonymous.

I'm looking for an automated backup solution as well if anyone knows about that.

I'm willing to do the work myself, but if you are someone competent, hit me up and we can talk about getting paid.

Thank You!!!


texts: How to scrape content from a Drupal Site?

texts:
I am a victim of Drupageddon on one of my sites and even though I patched Drupal core (maybe not fast enough) recently my Drupal database got completely messed up and my webhoster confirmed there were massive attacks on the Drupal database.

Now, I have the luck that my site still is visible including all content. But I cant login anymore, getting PDOexceptions and so on.

My question is, how to backup the content (nodes) from remote, maybe scraping node by node, field by field? (Reverting to backups before Oct/15 is no option currently, I need all the content.)

Update: The database is a mess, I can not login because of database errors. I need a remote solution. Or maybe I can extract the content from a database dump?


texts: How can I query and order nodes with multiple date field values within a specific range?

texts:
I'm trying to get nodes that have date fields (multiple instances in some cases) and display them sorted ascending by start time for a given date. For illustrative purposes, here are some events and their date field values (start time).

Event A

4/2/17 8:00AM
4/3/17 2:00PM

Event B

4/3/17 11:00AM
4/3/17 5:00PM

Event C

4/3/17 6:00PM

Event D

4/4/17 4:00AM

I'm using EntityFieldQuery to gather the events with dates on 4/3/17 and order them using this code;

$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'event')
->propertyCondition('status', 1)
->fieldCondition('field_datetime', 'value', array('2017-04-03/T00:00:00', '2017-04-04/T00:00:00'), 'BETWEEN')
->fieldOrderBy('field_datetime', 'value', 'ASC');

I get the nodes ordered like this;

A, B, C

but I want them ordered like this;

B, A, C

I guess the fieldOrderBy method is looking at all the date field values and ordering that way, which includes dates other than my target (4/3/17).

Anyone know how to accomplish this (with EntityFieldQuery or without)?


texts: How to change the default selection in views filter?

texts:
Content type has two fields: Property type and bedroom.
I created a view where above fields were exposed to visitors.
When I visit my site, I see -Any - is the default value for the both fields. First field is the property type and the second field is the bedroom field.

Property type field :

Bedroom field:

How can I replace the default value -Any - by the corresponding field label? For example, for property type field, I like to see Property Type as the default value and for the bedroom field, I like to see bedroom as the default value in the drop down list.


texts: How to show user profle edit tab as a default tab on user profile page?

texts:
I want to show user profile edit tab as a default, on page load its content must show. Like we have option in quick tab module, in which you can select which tab must show on page load.

How to perform this?


texts:
I am making an AJAX call to /file/.json. Webserver log says DELETE /services/file/5710.json HTTP/1.1 200, console log says the file has been deleted; yet the file is still there when you go here. What am I missing? My code is as follows:

$.ajax({
  url: 'http://www.rejicast.com/services/file/' + oldFID + '.json',
  type: "delete",
  dataType: "json",
  beforeSend: function(r) {
    r.setRequestHeader("X-CSRF-Token", token.token)
  },
  success: function() {
    console.log('Deleted the file');
  },
  error: function(xhr, status, err) {
    console.error(xhr);
    console.log(status);
    console.log(err);
  }
})

(Note: oldFID is something I set at the beginning)

UPDATE: As per @Clive's answer, there is still a reference to the file in the database as seen below .


texts: Entity form Submissions automatic numbering over 1000

texts:
I have reach an entity form submission count that has hit 1,000.

The problem I have is the URL is '/entityform/1,000' - notice the comma. This screws up the link to the url. I have searched and cannot find how to remove the comma when entityform creates the link.

I have check alias patterns, module settings and every where else I can look within the drupal/module configuration.

Can someone help me figure out where to make this update?

Thank you!


texts:
I have a new Drupal 8 site, where I installed few minor modules and Commerce 2.0 beta3, but the site has only 2 nodes so far, even the commerce tables are empty.
However even with PHP memory limit set to 2048M it exhausts it all giving me this message:
Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 10464376 bytes) in /var/www/website/public_html/modules/backup_migrate/vendor/backupmigrate/core/src/Source/MySQLiSource.php on line 347

For this example the PHP memory limit was 1024M, I tried database only backup with cashe tables excluded.
I remember being able to run B&M with 256M allocation on D7 and hundreds of nodes, loads of modules and content types.
As I don't see this issue anywhere on the internet or reported as an issue on the module page, I'm left to believe there has to be something specific to what I may have done wrong?
In the log I also find the following (with full error reporting on):
Notice: Undefined index: settings_profile_id in Drupal\backup_migrate\Form\BackupMigrateQuickBackupForm->submitForm() (line 84 of /var/www/website/public_html/modules/backup_migrate/src/Form/BackupMigrateQuickBackupForm.php)

System specs:

Ubuntu server 16.04
Running Apache server
With PHP7
Drupal version 8.2.3

EDIT:
I found a few extra errors on different tests:
Notice: Undefined index: groups in BackupMigrate\Drupal\Config\DrupalConfigHelper::addFieldsFromSchema() (line 91 of /var/www/website/public_html/modules/backup_migrate/src/Config/DrupalConfigHelper.php)

Warning: Invalid argument supplied for foreach() in BackupMigrate\Drupal\Config\DrupalConfigHelper::addFieldsFromSchema() (line 91 of /var/www/website/public_html/modules/backup_migrate/src/Config/DrupalConfigHelper.php)

Notice: Undefined index: #description in BackupMigrate\Drupal\Config\DrupalConfigHelper::addFieldsFromSchema() (line 116 of /var/www/website/public_html/modules/backup_migrate/src/Config/DrupalConfigHelper.php)

Where the last one appears twice in a row every error sequence.
Appreciate all help!
Alari


texts: How do I install dependencies for commerce using the Composer manager module

texts:
I installed the composer manager module and enabled it. I have tried initializing it from using drush in the command line and failed using the command drush composer-manager-init.

I am confused on how to add the libraries intl, address, pricing and tax to my site.


texts: Dropdown Menu with 20+ items gets cut off by a views content rotor

texts:
I'm trying to spruce up a Drupal 6 site, but I'm running into some issues with a views slideshow (specifically, rotorbanner) and having a menu with ~20 items.

When the menu expands, I can see all the links, but whenever I mouseover on a link that's within the "slider" block, the list disappears.

My thought was to fix this by just making the menu two column, but I'm running some difficulties with that and maybe fixing this will be easier.

I'd prefer not having 20 menu items, but that is the way my org does things, alas : )

For an example, go this dev site and hover over the "networks" section on the menu

Thanks!


texts:
I am programmatically creating primary menu's which has the node content as links . So as soon as the node content is created, a primary menu link to that node content is created.

So while creating menu's ,I am also setting the languages of menu to which it belongs. So lets say if the node content created is in french, then a primary menu link is created with the language set to french.

The problem is despite the menu item's language is set, Still it gets displayed in all the other two languages as-well (English, German). I have installed Menu translation module as well but still its not working.

So how to implement multilingual menu's programmatically?

Tks
Vil


texts: Upgrading from d6 to d7: getting puzzling 'requirements problem' error

texts:
I am trying to upgrade from d6 to d7 and I'm getting a requirements problem immediately after running upgrade.php. It seems there's some crucial information missing. For me, at least: absolutely no clue what is happening here.

I've got the Ad module (as well as ad_image, ad_flash) enabled

The error that is thrown back at me is:

  upload (Missing): Unresolved dependency, Flash Ad requires this module.
  upload (Missing): Unresolved dependency, Image Ad requires this module.

See screenshot


texts: How to theme webform elements (radio buttons etc.)?

texts:
I would like to know how to theme Drupal 7 Webform elements?
I want to change the HTML structure of every element, not just wrap form with div or something like that. And I want to leave theme's elements as they were.

EDIT:
I would like to add class to label and input type radio button.


texts:
I am trying to run address field on my web page, but I get an error

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

So I checked the logs and get

  Error: Class 'CommerceGuys\Addressing\LocaleHelper' not found in Drupal\address\Plugin\Field\FieldFormatter\AddressDefaultFormatter->getValues() (line 286 of /var/www/mywebsite/modules/contrib/address/src/Plugin/Field/FieldFormatter/AddressDefaultFormatter.php)

I checked my composer.json file and have the following required

 "drupal/address": "~1.0",
 "commerceguys/addressing": "1.x-dev",

ran

 composer update drupal/address --with-dependencies

from https://www.drupal.org/project/address
but still getting the same error, I believe the error is commerceguys/addressing, but composer update says there is nothing to be updated. Any directions to my problem will help a lot, thanks.


texts: In Drupal Commerce - Rules configuration. What is the default operator in the conditions section?

texts:
I'm setting up Drupal Commerce in the checkout Rules section. But this question also applies to any Rules.

Currently I have 3 conditions in my rule set. By default what is the default operator in this section? Is it an OR or AND? I see you can add these in manually, but it would be good to know what they are by default.

  Data comparison

  Entity exists by property

  Data comparison


texts: How can I debug white screen when running install script?

texts:
I'm doing a fresh install of drupal7 on Ubuntu following these instructions.

When I get to the point of running the install script (by pointing the browser at localhost/drupal7/install.php) it just gives a blank screen.

Most questions/help about the Drupal blank screen relate to site setup but as this is a new install, I haven't created any sites yet so am unable to figure out what to do.

Does anyone know how to debug or move past this issue?


texts:
I installed a custom module that created few content type that I'm no longer need it. I disable and uninstall that module but I still have the content type. And it bother me every time I see it. So I try to delete it however, I cant because for some reason doesnt have the delete button. So now I have 5 content type that I don't need. Can anyone have a solution on how to remove these content types ?

In this picture you will see that doesnt allow me to delete the content type.


texts:
I am trying to integrate travis test bots to my module. Travis can run the test correctly, in console log, I can see drush run-test discover pass and fail assertions, but the final result is still passed. Is there any trick to tell Travis know that the test is fail?

My test code is: https://travis-ci.org/andytruong/at_demo_travis/builds/12999422

Thank you


texts: Additional file entity fields in widget_form

texts:
I've added additional fields to my file entity types and would like to have them in upload widget, just like file description.

How can I add my custom fields element using field_widget_form_alter? (if that's the way to go)


texts: Increasing performance of cache_form on high traffic sites

texts:
I am noticing a significant performance increase in my load testing when this table is small, but due to a large traffic site this is growing very quickly.

I have read that it is not a good idea to move this into an "in memory" cache like redis or memcached but can this be moved to a noSQL database for example?

My issue is that even with frequent clearing of old records the performance is struggling and my main solution is to take the database offline and optimize the table to reduce the physical size of the table in MariaDB.


texts: How to create sortable checkboxes using the form API?

texts:
I'm using Drupal 7 and I need the ability for the user to choose from a list of options and put those options in order. I am using type checkbox and passing in an array of options to create the list.

I need to be able to check the options needed and sort them.

The form checkbox creation is fairly straightforward, but doesn't appear to have a weight option for the individual checkboxes or really any attributes except value.

Any help would be appreciated. Thank you.

$form[$key]['articleFields'] = array(
    '#title' => t('article Fields'),
    '#type' => 'checkboxes',
    '#description' => t('Choose the fields you want selected'),
    '#options' => $articleFields,
    '#default_value' =>$articleFields_checked,

);


texts: Query remaining field names from a database table

texts:
There's a database table. I know only one field name on the database table: username. How do I view  remaining field names on the table?
namespace Drupal\fixx_helper\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class AutocompleteController extends ControllerBase
{
   public function handleAutocomplete(Request $request)
   {
      $results = [];

      $input = $request->query->get('q');
      $database = \Drupal::database();
      $my_query = $database->query("select distinct username from banner_exports.ws_students where username like '$input%'");

      while($result = $my_query->fetchAssoc()){
         $matches[] = array('value' => $result['username'], 'label' => $result['username']);
       }
       return new JsonResponse($matches);

}}


texts: Get value file_save_upload from $form_state['input']

texts:
How can I get the right value to use in $file = file_save_upload($public_file, $validators, 'public://', FILE_EXISTS_REPLACE);

$public_file = $form_state['input']['files']['public_file'];

This upload field comes in the form via an ajax request so it comes in $form_state['input']['files']['public_file'] according to DSM. But when I do this it doesn't work.

I only got this function to work when the public_file is in the base of a form $form['public_file'] and entering public_file in the first value of file_save_upload.

But that isn't possible this way because of the ajax generated form.

If anyone knows how to get this value I would be very thankful. My code is below:

function push_notifications_edit_app_form_submit($form, &$form_state) {
    $title = $form_state['input']['title']['changethis'];
    $app_id = $form_state['input']['edit']['app_id'];
    $gcm = $form_state['input']['edit']['GCM'];
    // $ios = $form_state['input']['edit']['iOS'];
    // $ios = $form_state['input']['hidden_ios'];
    $oldid = $form_state['input']['oldid'];
    $ios_mode = $form_state['input']['edit']['ios_mode'];
    $public_file = $form_state['input']['files']['public_file'];

    $validators = array('file_validate_extensions' => array('pem'));
    $file = file_save_upload($public_file, $validators, 'public://', FILE_EXISTS_REPLACE);
    $ios = $file->filename;
    if ($file) {
        drupal_set_message(t('Thank you for uploading private file. You can download it from @url',
        array('@url' => file_create_url($file->uri))));
    }
    $query = db_update('push_notifications_api')
        ->fields(array(
               'app_id' => $app_id,
               'GCM' => $gcm,
               'ios' => 'hoi',
               'ios_mode' => $ios_mode,
            ))
        ->condition('app_id', $oldid)
        ->execute();
    drupal_set_message(t('@title has been updated succesfully.', array('@title' => $title)));
    dsm($form_state);
}

And in the _form function:

$form['#attributes']['enctype'] = 'multipart/form-data';

$form['replace_textfield']['public_file'] = array(
    '#type' => 'file',
    '#title' => t('iOS Certificate File (.pem)'),
    '#description' => t('Upload your iOS certificate file here. Currently you are using: <strong>@cert</strong>', array('@cert' => $ios_key)),
    '#weight' => 35,
);

$form['replace_textfield']['edit']['ios_mode'] = array(
    '#type' => 'select',
    '#title' => 'APNS Environment',
    '#description' => 'Select the active APNS Environment. Please note that development certificates do not work with apps released in the Apple app store; production certificates only work with apps released in the app store.',
    '#options' => array(
        'prod' => 'Production',
        'dev' => 'Development',
    ),
    '#weight' => 40,
    '#value' => $ios_mode,
);

$form['replace_textfield']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Edit',
    '#weight' => 40,
);


texts: I am maintaining a calendar for a website where events can be listed in. This year is finishing, which means that soon there will be hundreds of events that need to be put in the calendar for next year. Is there a better way of doing this than manually clicking new page for every event? Ideally I would like to be able to fill a dozen events or so in one go.


texts:
My THEME.info.yml file reads:

name: 'name'
type: theme
description: 'description'
core: 8.x
base theme: stark
screenshot: images/image.png
libraries:
  - THEME/navbar

and my THEME.libraries.yml reads:

navbar:
  css:
    theme:
      css/navbar.css: {}
  js:
    js/scrolling.js: {}
  dependencies:
    - core/jquery

From all the guides I've found online, this should mean that navbar.css and scrolling.js get included on all pages that use the theme. But that isn't happening. What have I done wrong here, or what steps do I need to take to figure out why it isn't working?

In case it's relevant, the file structure is:

drupal_root
    themes
        custom
            THEME
                css
                    navbar.css
                js
                    scrolling.js
                images
                    image.png
                THEME.info.yml
                THEME.libraries.yml
                THEME.theme

The jQuery code in scrolling.js is just:

$(window).on("scroll", function() {
  if ($(this).scrollTop() > 50) {
    document.getElementById("logo").style.width = '150px';
    document.getElementById("logo").style.marginTop = '0px';
  } else {
    document.getElementById("logo").style.width = '300px';
    document.getElementById("logo").style.marginTop = '20px';
  }
});

When I manually add

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="{{ theme_path }}/js/scrolling.js"></script>
<link rel="stylesheet" href="{{ theme_path }}/css/navbar.css">

to the top of html.html.twig everything works fine. But as I understand it, this is not considered the proper way of going about things, so if possible I'd prefer to do it using libraries.

The extremely helpful comment added by (I think) Ivan Jaros which was unfortunately and rather rudely removed helped me to find that I needed to add <head-placeholder token="{{ placeholder_token|raw }}">, <css-placeholder token="{{ placeholder_token|raw }}"> and <js-placeholder token="{{ placeholder_token|raw }}"> to my html.html.twig file. This helped somewhat: it's now including the CSS file. However:

It didn't manage to include the js file, for whatever reason.
The head-placeholder token is mostly useful, but seems to be overriding the favicon that I had already specified. Is there a way to keep the other stuff it gives without the link rel="shortcut icon" that it's including from core?


texts: In Views, what is the difference between "Show Fields" and "Show Content" under Format?

texts: In the Format section you have the option Show: Fields. That is the one I usually use. However, you also have Show:content. What is Show:content and how is it different? When would I want to use it instead of Show:fields?


texts: Basic Auth working but simple auth not working for create user

texts:
I am totally stuck here in Drupal 8 REST API, any help is very appriciate.

Problem:

I am using Drupal 8.3.x, simple_auth module to generate Auth token for REST. When I try to create user by Authorization Bearer then its not working but when I try to create by Basic Auth then it works fine. I also enabled permission for user REST.

See Permission for user resource: URL: admin/config/services/rest/resource/entity%3Auser/edit

Postman Data:

Request header:
Authorization:Bearer token_value
Content-Type:application/hal+json
X-CSRF-TOKEN:OWp4RVNjlQbdjq-s6CMjNRIcfNiYsHp1L7Of87vJH2w

In Error Log:
League\OAuth2\Server\Exception\OAuthServerException: The resource owner or authorization server denied the request. in League\OAuth2\Server\Exception\OAuthServerException::accessDenied() (line 165 of /var/www/html/d8/drupal-8-composer/vendor/league/oauth2-server/src/Exception/OAuthServerException.php).


texts: How to override/enhance file_save_upload() function of file.inc?

texts:
For a specific requirement, wherein whenever an image is uploaded to a particular field of a node, a watermark should be added to it, I made changes in file_save_upload() function of file.inc

if (!drupal_move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->uri)) {
    form_set_error($source, t('File upload error. Could not move uploaded file.'));
    watchdog('file', 'Upload error. Could not move uploaded file %file to destination    %destination.', array('%file' => $file->filename, '%destination' => $file->uri));
   return FALSE;
}
else{
    process_image(drupal_realpath($file->uri));
}

But these changes will be lost whenever Drupal core will be upgraded. So what is the best way to override/enhance file_save_upload() function of file.inc or any function in the core drupal?


texts:
I would like to upgrade from drupal core 7.7 to 7.x-dev, is this possible using Drush?

UPDATE:

Ok, looks like either I needed Drush 4.5, or the process of updating Drush from 4.4 corrected something with the installation, as drush up drupal-7.x worked, and I'm noticing that drush up now shows all installed modules everytime.


texts: How to load aggregated styles / js in an 'external' script via DRUPAL_BOOTSTRAP_FULL?

texts:
I have an external script / php application that I now have to implement into a running D7 site. So far DRUPAL_BOOTSTRAP_FULL seems to do the job just fine – I can read the session, check the user etc.

But I am currently stuck trying to load the $styles and $scripts into the head of that external application. I tried drupal_get_css();, also checked the $variables and also tried template_preprocess_html(); to preprocess the  variables –– but D7 won't return anything.

What I have so far:

define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
$base_url = 'http://'.$_SERVER['HTTP_HOST'];
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

I hope somebody can direct me in some direction – any pointers appreciated. Thank you!

Update: The solution suggested by oksana-c works quite well if you 'only' need to load the top css and js files. The site I'm working on however caches and aggregates all js and css files into one – including various files provided by different modules… So what I would actually need to find out is how to link to those aggregated js and css files. Anybody?

Update2: I could 'crawl' the folders where the aggregated css and js are stored – however currently I can see 4 different js files and 4 different css files in the head. Also according to the files' timestamps sometimes only 2 files were generated and loaded in the past – so I have basically no indication of how many of the most recent files I should include. Probably some hook would help that would let me list whatever cached/aggregated files are loaded at this time – but I still have no idea where/how to hook into the caching/aggregating functions…


texts:
We have a content type that up until today was 100% driven by a feeds importer on a D7 site from an XML file (from a third-party system). This importer ran nightly and was set to "Unpublish non-existent nodes" which worked perfectly to remove items not available anymore.

Due to a business needs change we now need to manually create a couple of nodes of this specific content type and we don't want the importer to unpublish these specific nodes. Modifying the third-party system is not an option so the only possibility that we've come up with is to create a local file (CSV/XML/whatever) and create a new importer to run after the original importer to re-publish them.

We could also locally consume the original file and merge it with our custom node list but this seems like more things could break.

Is there another solution to this problem that we're missing?


texts: How to add a "company name" as a user value for permissions and a data variable

texts:
I am creating a site that allows multiple different company's access to separate resources. Access to resources is dependent on the user's role and the company they are registered to.

Sample User Roles:
Mechanic
Scheduler
Parts Distributor
Driver
Admin

Sample Company's:
Joe's Auto Repair
Car Repair USA
Pro Tire & Oil

Each user has access to only his company's data and the data that is associated with the permissions attached to his role.

How can this be done? Am I going to need to code custom modules?


texts: Hook before the file insert, before the file come on the server?

texts:
I want alter the URI's files before they are stocked in the server.
The file insert, I mean, everywhere/time a file is uploaded via Drupal (all insert file process, not only when an user add a file via a form)

Is it possible ?

An example :
With drupal defaults settings, files ares stocked in the files directory (drupal/sites/default/files)

I want stock files in another directory (out of drupal main directory, by exemple in the directory /save/files)

And

I want to organize files like this :
files/pictures/01_May
files/pictures/02_May
...
files/pictures/day_month
(its an exemple for pictures, maybe there is another structure for the video etc..)

So, when the user or the drupal code (.module, via the drupal api) upload a file to the server I want automatically stock this file in the directory /save/files)
With the hook insert I can change the URI of the file, but during the hook insert the file is ulready uploaded in the server.

I'm looking for a way for move any files uploaded to the good directory before files are stocked in the server