texts: Displaying Webforms on Content Types in Page Manager/Panels

texts:
The Webform module allows for a webform to be attached to each Content Type of the site.  I can "Enable webform functionality" on my Page and Blog Content types and don't need to use a separate "webform" content type, very cool!  This works great with Entity View Mode displays.

However, when using the Node Template in Page Manager, I can't get the Webform to render after adding the "Node being viewed" Webform element.

My goal is to use Page Manager to display every node, with the possibility of a unique webform attached to that node.

I brought this up at a meetup recently and was advised that it may be a bug.  But I didn't think to ask where!  So, if you think I should bring this up in an issue queue, where do you think that would be, Webform, ctools, or Panels?

Thanks,
Jim


texts: Views agenda page not updating (still cached)

texts:
I have a Views page to create an agenda of events. The views has a filter to show only agenda items that are in the future. I created a similar setup for multiple site but on this one the agenda is not updating by itself the page is saved in cache and updating the content its showing is only possible when I empty the cache by hand (each day). When I do not empty the cache the page also shows past events.
I tried changing the cache settings of the View, but this doesn't change a thing.
What can should I do to make sure the agenda is always showing the right future items?


texts: How to apply patch file to views module in Drupal 7

texts:
I have problem with my views module. In some occasions it displays this deterrent warning:

Notice: Undefined property: views_handler_field_field::$original_value in views_handler_field->render_text() (line 1118 of C:\wamp\www\novine\sites\all\modules\views\handlers\views_handler_field.inc).

I think I found the patch that could work and save me from this buggy thing. My problem is how to apply downloaded patch to views module. I placed patch file in views folder, cached site, and  nothing happened. That was obviously naive try.
Can someone help me and tell all applying patch procedure? Thanks in advance!


texts: Send Email upon Registration to Author of node

texts:
I have searched and can not find anything similar.

I have a Rule, Event = send email after someone registers for an event.
I have the rule sending to the user just fine. However, I am trying to also email the Author of the page and I can find the correct replacement pattern.

I have an action Fetch Entity by ID Value=registration - DATA-Selector=registration:author:uid

I have tried many patterns:

[node:author:mail] mail - Nothing happens
[registration:author:uid] uid - give me the logged in user id
[registration:author:uid] reg-a-uid  (this give mne the id of the logged in user- not the author on the page.)
[node:author:uid] node-a-uid
[site:author:uid] site-a-uid
[registration:author] reg-author - show logged in user
[registration:author:mail] reg-author-mail - show logged in user

I am at a loss when trying to figure out how to pull the author of the node/page to email them.
Any ideas???
Thanks

[EDIT]

I was able to get the Author to print out.

author: [registration:entity:author]

Any ideas to pull the author first name, email and phone number???

Please any little thought would help.
Thanks


texts: Prevent site from being indexed by search engines?

texts:
I have two requirements for my site

I don't want my site to be indexed by search engines
Anonymous users should not be able to see any content of the site

I would have been satisfied with ip restriction in the .htaccess file but I cannot use that because this site is part of a multisite setup and as far as I know one cannot use .htaccess files in sites/mysite1/.htaccess and I don't want to go down the symlink route at the moment.

Right now I am using:

Shield (for Apache authentication and to prevent non content elements from being previewed)
Metatag (<meta name="robots" content="noarchive, nofollow, noindex, noodp, nosnippet" />

but thinking about it some more I thought that perhaps just using the Shield module wil prevent my site being indexed. Or even just disabling the  View published content permissions?

So my questions are:

Will the Shield module prevent my site from being indexed?
Will disabling the View published content permissions prevent my site from being indexed? (with the downside that part of the site can be previewed)


texts: Integer user form field with min 11 digits and max 11 digits

texts:
I need an integer form field with has a validation of min 11 digits and max 11 digits. In other words; the user has to fill in an 11 digit code.

How do i make this field and validation?

Update:

I managed the field by setting a min of 10000000000 and max of 99999999999. But now i get this validation message:

  RIZIV number: the value may be no greater than 99999999999.

How do i change this validation/error message to something like:

  Fill in your right 11 digits RIZIV number.


texts: Custom arrangement for fields with multiple values in Drupal 7

texts:
In Drupal 6 I used to make every sort of customised markup for CCK fields with multiple values. Usually this happened when I wanted to lay out thumnails for a gallery inside a table: I used to go into the relevant tpl.php file, grab the relevant $field_fieldname variable, loop through it, and print out the 'view' key for it, which contained the styled thumbnail, often linked to the original image and whatever.

Now, I'm a bit confused on how this should be done in Drupal 7. For now, I set up a suboptimal solution that goes like

    <?php foreach($content['field_gallery'] as $k => $v) : ?>
        <?php if(is_numeric($k)) : ?>
            <?php echo render($v) ?>
            <?php if((($k+1) % 4) == 0) : ?>

            <?php endif ?>
        <?php endif ?>
    <?php endforeach ?>

but it's obviously wrong. I can't seem to get my head around this, even after having read lots of docs about the Field API and theming for D7. Ideas?


texts: Is there a way to access the full list of results in a Solr search page?

texts:
I would like to manipulate the order of the results in an Apache Solr search result.

I'm using apachesolr together with apachesolr_panels.
In hook_apachesolr_process_results() I can get the $results for the current page, but I'm looking for a way to find the full list prior to pagination.

Edit: I'm asking about the result set as I'm not in control of the solr server and can't manipulate the XML file.


texts:
How do I remove js from a specified page?

templates.php


texts: How do I override a taxonomy/term/% list with a view?

texts:
I have a vocabulary attached to a content type. Only one term can be selected to categorize a node made with this content type. The vocabulary is called Vehicles and has terms 'cars, trucks, boats.' The content type is also named Vehicles.

I use path auto so that it shows [vocabulary:name]/[term:name] so when rendered it will show site.com/vehicles/trucks, for example, which will show all the trucks... typical Drupal stuff.. Ok...

Now, I have a View that is a page with a path 'vehicles.' It is setup to to display all of the items of content type 'vehicles.' This page view is also setup to take an argument 'taxonomy term id.'

Note that when the taxonomy term is present, the url alias generated for the taxonomy path is the exact same as as the Views page with an argument supplied:

URL Aliased taxonomy path = vehicles/trucks.
Views page with argument = vehicles/trucks.

This is on purpose. My goal was to show all results of that content type when an argument was not present, and when it was present, it would most importantly filter the results based on that taxonomy term AND keep the same fields and structure as without the argument (same as site.com/vehicles).

The problem is, this is not working as expected.
site.com/vehicles correctly shows my view and related filters.
site.com/vehicles/trucks shows just the regular, unformated taxonomy list supplied by Drupal.

Is this because Taxonomy term ID argument is not configured correctly?

Is this a weight issue where taxonomy hooks are firing after Views? If so, how can I rearrange the weights here so that it fires correctly and gives me the results I need?

I know what you are going to suggest - that Views comes with taxonomy/term/% view to override drupal default views.

However, this is not going to work in my case. I have multiple content types each with its own vocabulary and each with its on view and distinct set of fields (houses and cars, for example have very different field sets). The taxonomy/term/% would work if all content types had the same fields, then I could just mimic those in that override, but since that is not the case, how can I correctly get my path with argument to show the results based on that vocabulary term and keep my field structure?

Sorry if that was confusing. A link to the site for reference http://www.buyagainbaby.com. The site does currently use taxonomy/term/% as an override, but again, that has to change so that each view is responsible for how it renders its result set based on taxonomy.


texts: Is there a module or easy way to break up nodes into multiple pages?

texts: Is there a module or easy way to break up nodes (ie blog posts) into multiple pages?


texts: How to preserve special characters like '&' in the views exposed filter form?

texts:
There is a view with exposed filters and few more filters added using hook_views_exposed_form_alter. Now these form elements/filter values are getting passed in the url like http://my_site?key1=value1&key2=value2 .

Now when I add value something like abc&xyz i.e values having special characters "&", form element does not take & as the default value instead it displays abc.

I need to encode this "&" to %26 and pass in the url without encoding other "&" that separate the key-value pair in the url.


texts: Create second button and reload form page

texts:
I have a form with Entity Registration module.
I have to add another button in order to save and add another account to registration.
For this i created a second module and i try to overide the first module. I created a hook :

function mymodule_form_alter(&$form, $form_state, $form_id)  {
    // add second button
    if($form_id=='registration_form'){
        $form['actions']['save_reload'] = array(
            '#type' => 'submit',
            '#value' => t('Save and add'),
            '#weight' => 0,
        );
        $form['actions']['#save_reload'][] = 'mymodule_node_form_submit';
    }
}
function mymodule_node_form_submit ($form, &$form_state) {
    drupal_set_message('Test Submit');
    $form_state['redirect'] === FALSE;
}

Unfortunatelly it doesn't reload after the form is sent.


texts: Header and many components missing in Open Social

texts:
Just installed Open Social:
https://www.drupal.org/project/social

The problem is that there is no content on the front page. No header or other blocks. I have reviewed videos of installation on YouTube, and notice that there is a header, and many other blocks available by default immediately after installation. Why does my new instance of Open Social have nothing on the home page?

I followed the install instructions on the module page:
https://www.drupal.org/project/social


texts: How to login to an external website after drupal-login?

texts:
I would like know how I can login my user to an external website after drupal-login please ?

I use :

    $xenAPI = new XenAPI('http://xen.dev/api.php', 'MY_API_KEY', 'MY_API_KEYSALT');
    $xenAPI->login('Kyna', 'secret_password', 'http://theming.dev');

The login work on all page when I use HOOK_user_load(), but if I use HOOK_user_login(), don't work. I don't have an error, but ->login() create a redirection with an header and I think drupal-login overwrite my header on external script or create a redirection before my script.


texts:
My node alias pattern is [node:title].html. Some pages of the site shows a .html extension and some don't.

I don't know what is the best way to fix that (Update the aliases didn't work, and Deleting the existing aliases could make me a great mess because there are more than 20 pages in the site that almost each one of them has a customized alias).

What would you guys suggest?


texts: Where does redirect from default search to apachesolr_search occur?

texts:
We're using the apachesolr_search module on our site. (This is a site I inherited fully coded, so there's tons going on that I'm not intimately familiar with yet.) We have a search block that has been customized (see this post for details; we did eventually get the radio buttons to display, although in a really dirty, non-drupal way.)

I'm trying to get the form values on submit. Forgetting for a moment the radio buttons, I can't even figure out a way to get the value of the search box. Obviously it's getting passed to the solr search, but when I look at the Net panel in Firebug, there are no POST requests, only GET. In my submit function (which does run), I've tried print_r('$_POST'), echo $form_state['values']['search_box'] (where search_box is the element name of the actual form element), tried looping through $form_state and printing all key/value pairs... nothing. Not a single one of these returns anything.

Obviously there's a redirect occurring somewhere that sends the value of the search_box to the solr search module to build the GET request, but I can't for the life of me figure out where it's happening. I think in order to see the values of the posted form, I'd need to intercept the values before the redirect - how do I do that?


texts: How to add client side validation to form via FAPI?

texts:
I can't figure what to add Client Side Validation for form fields.

'#element_validate' => array('_file_generic_settings_max_filesize'),

I also don't know which value to put for different types of validation such as digit, email etc.
    '#element_validate' => 'email',

Also if I use this documentation https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x/#element_validate:

'#element_validate' => array('email'),

it states that it needs to be string not an array.

And after all this documentation doesn't state that how to add validation instead just creating own validation:
https://www.drupal.org/node/1324788


texts: Adding conditional statements as Math expression to custom text fields in views

texts:
I have created views in which i have added custom text and Math expression.
I displayed view in table format
I created one Math expression which is noticed below:

[Field 1] - [Field 2]

I have displayed this expression into another custom field in views.

Now i want to add some condition statements.
That is

If [expression] >= 0
 'display something'
else
 'other texts'

Is it possible to add conditional statement in Math expression views?


texts: How to remain logged in when switching languages via domain Drupal 7

texts:
I've got a site which will run in different languages.
The language is determined based on the language domain, and the site will thus exists as example.com, example.de, example.fr, example.co.uk and so on. All sites run on the same codebase and database.

I've experimented with $cookie_domain in settings.php, but cookies will not be shared across top level/language domains. I've also had a look at the Bakery module, but that does not work for top level/language domains either.

Does anyone have experience with this, or does anyone know what my options are?


texts: How to set a new value in a paragraph field on submit?

texts:
In an edit form for a content with paragraphs, I set errors on the paragraph specific field with this particular syntax:

$form_state->setErrorByName('field_paragraphs][' . $key . '][subform][field_sharepoint_file_url][' . $key2, t('Invalid URL'));

(see the missing square brackets at the beginning and at the end, solution found here)

This is working well.

However, I also need to register a different value on this field, and I can't seem to find the right way to do so.

I've tried to do this in a submit callback:

$form_state->setValue('field_sharepoint_file_url', $data->alias);

Or by retrieving the paragraph object in the hook_ENTITY_TYPE_presave:

/*
 * Implements hook_ENTITY_TYPE_presave()
 */
function mymodule_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->getType() == 'page') {
    $result = $entity->get('field_paragraphs')->referencedEntities();
    if (!empty($result)) {
      foreach ($result as $paragraph) {
        /* @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
        if($paragraph->getType() == 'sharepoint_file') {
          /* @var \Drupal\Core\Field\FieldItemList $url */
          $urls = $paragraph->get('field_sharepoint_file_url');
          /* @var \Drupal\Core\Field\Plugin\Field\FieldType\StringItem $url */
          foreach ($urls as $url) {
            // [...]
            $paragraph->set('field_sharepoint_file_url', $data->alias);
          }
        }
        $paragraph->save();
      }
    }
  }
}

But the new value is never registered in database.

Thanks for any tip on this.


texts: How can I set product price per taxonomy term on Ubercart?

texts:
I need price per taxonomy terms for products. Here is what I need precisely. So when I add products 'X', 'Y', 'Z' to Ubercart I sets them taxonomy term 'Offer' which has price 10$. These products then have same prices. So when customer add any of these products from this term to cart it will get same price for every product.

Thanks for help M.


texts:
I'm trying to create a View Block to display related information on a node.

I'm creating an image gallery where each image node is tagged with one/more taxonomy terms, and a block on each of those nodes then displays a list of users who have expressed an interest in the same taxonomy term(s).

So the node is tagged with e.g "landscape" and a user has a Profile2 profile in which they have have also selected "landscape" with a taxonomy ref field.

I'm having trouble building the view to achieve this. If I create a new view with a block and select that i'm displaying "Profiles" from the initial dropdown, views seems to remove some of the kinds of objects I can choose in the Contextual Filters or Relationships menus: Node isn't available for linking in a relationship.

If I go about in the "other direction" and make a view of Nodes, then try and create relationships backwards to the Profiles I want, I'm unable to select fields present in the Profile for output - the only fields available are those on the Node.

It seems that by choosing a specific kind of object to list, Views immediately excludes certain possibilities for joining.

Is this not possible? I know what the exact SQL would be, but I'd rather not write a module if a View would do.


texts:
I have a view in Drupal 8 that looks as follows (see screenshot). To make the long story short, I need to make this view output a fixed HTML block (piece of code, not Drupal Block) and not pull any dynamic data from the respective content type.

What is the most efficient way of doing this?


texts: Unknown column 'base.i18n_tsid' when using Term Reference Tree module

texts:
I've installed Term Reference Tree module to create hierarchical tree to select checkbox and it works fine in English website, but when I am using the same in my Spanish website it gives me following error:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.i18n_tsid' in 'field list': SELECT base.tid AS tid, base.vid AS vid, base.name AS name, base.description AS description, base.format AS format, base.weight AS weight, base.language AS language, base.i18n_tsid AS i18n_tsid, v.machine_name AS vocabulary_machine_name FROM {taxonomy_term_data} base INNER JOIN {taxonomy_vocabulary} v ON base.vid = v.vid WHERE (base.tid IN (:db_condition_placeholder_0)) ; Array ( [:db_condition_placeholder_0] => 2 ) in DrupalDefaultEntityController->load() (line 191 of /home/lawand9/public_html/law/includes/entity.inc).

I dont know why it happens. Is it because of multilingual module or taxonomy translation?


texts: How to save datetime field value in config?

texts:
I have a custom module (mymodule) with a settings form. This form contains a datetime field (mydate) which I want to save in my modules config.

When I try to save this form I get an exception:

  Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type for config element mymodule.settings:mydate in Drupal\Core\Config\StorableConfigBase->validateValue() (line 160 of core/lib/Drupal/Core/Config/StorableConfigBase.php)

The form field:

$form['mydate'] = array(
  '#type' => 'datetime',
  '#title' => t('My date'),
  '#default_value' => $config->get('mydate')
)

The form submission handler where the error occures:

$config->set('mydate', $form_state->getValue('mydate));

I guess I have to set up my config schema to set up the "right type". Currently I have this one but it does not solve my issue:

mymodule.settings:
  type: config_object
  label: 'fancy module settings'
  mapping:
    mydate:
      type: datetime
      label: 'My date'

Any idea what I'm doing wrong or what is missing?

PS: using Drupal 8.2


texts: How do I disable output buffering while still preserving my site's appearance?

texts:
Whenever I try disabling output buffering, my site's layout gets displayed incorrectly. Why is that and is it possible to disable output buffering without wrecking my layout? Thanks.

edit 1:

I edited theme.inc (a Drupal's core file) and commented out ob_start and ob_get_clean. This results in all the content that's supposed to appear between the <body> tags being printed before the <html> tag. This is also the outcome if I replace ob_get_clean with ob_get_flush. Replacing it with ob_get_contents returns only the content without the <body> tags and everything else outside of it.

edit 2:

Did some further editing and I think I found out why turning output buffering off results in layout problems. The sequence in which the template files are called is not necessarily in the same order as they're supposed to appear. In fact, the file with the <html>, <head>, and <body> tags is called last. I don't know if that's normal or if it's because of my theme. In any case, it looks like disabling output buffering isn't an option for me.


texts: Why can't I delete certain content types?

texts:
I have a Drupal 7 site, and under the Content Types menu, only certain types have a 'delete' link under the 'Operations' column.

All of the content types have the links for 'edit', 'manage fields', and 'manage display', but only some have 'delete', while others don't.

I checked my permissions for my user, and I do have Administer content types -- but that appears to be one global permission for all content types, so I still don't understand why some are deletable while others aren't.

Why do only certain content types have a delete operation?


texts: When creating content, I'd like to have something akin to a drop down menu.  You could hover over an item and a list of checkboxes would appear.  Essentially it'd be a Select List with sub-items.  Is there any easy way to do this?


texts: Is there a hook function for a module's settings form being submitted?

texts:
I am maintaining a cache of data in my module using $_SESSION, which gets rebuilt after an amount of time has passed.  This works fine, but I now need the cache (session object) to be cleared when the user submits a change to the module settings.

Is there a hook I can implement that will be called on form submission?  I have already implemented mymodule_form_validate, but this doesn't feel like the right place for it, I would prefer a hook that fires only when validation is successful.

I have tried checking for the rebuild flag in mymodule_form, but that doesn't seem to work:

function mymodule_form($form, &$form_state) {
    if($form_state['rebuild'] === true) unset($_SESSION['mymodule_cache']);
    //form elements and stuff...
}

Update

Trying to follow marcvangend's answer, but I'm struggling.  I've implemented hook_form_FORM_ID_alter:

function mymodule_form_mymodule_form_alter(&$form, &$form_state, $form_id) {
    echo $form_id.'<br>';  // mymodule_form
    $form['#submit'][] = 'mymodule_form_submit';
}

and this seems to work, in so much as the form id traces out as expected.  The trace in my submit function never seems to appear and the session object is unchanged, although the form values do submit:

function mymodule_form_submit($form, &$form_state) {
    echo 'form submit';
    $_SESSION['mymodule_cache'] = array();
}


texts: Can the speed of my cron job be improved?

texts:
Can I improve my cron job speed?

Ex: it takes me 30 seconds to complete a certain cron job. Can I make it do this faster?

Does cron speed depend on the server machine?


texts: Referencing CSS file from theme library inside Embedded Widget Paragraph type

texts:
I have an article page in Drupal 8 that contains a chart (inserted into the page using Text paragraph). The chart uses CSS classes that I have created inside the global stylesheet. It works, but I don't want these CSS classes to be loaded on every single page on my website.
I'm thinking that I would move the CSS classes into a separate file. Then I would move the HTML code for the chart into an Embedded paragraph and reference the theme library.
I'm new to Drupal 8 theming so I'm not sure how I would go about doing that. Can someone give me the general steps?
I think need to do the following.

Move CSS classes to a new file
create a library refencing the new CSS file that is not loaded by default
Add the CSS file URL to the embedded widget "Javascript Source" field

I'm not sure how to add the library refence to my theme or to make it not load by default.


texts: How can I create a custom ajax callback command?

texts:
I found different type of ajax commands like htmlCommand, invoke command etc. I want to create a custom ajax command that sets the response of ajax callback as the value of specifying markup in the callback argument. Is it possible? I created one as per this tutorial.

    public function ajax_call_back_function() {
       $response = new AjaxResponse();
       $element  = $form_state->getTriggeringElement();
       $returnDelta = $element['#array_parents'][2]; // get levels
       $delta = $element['#value']; // eg : 944 THis is the ata i want to set as the value of markup
       $response->addCommand(new ReadMessageCommand($delta, $returnDelta));
       return $response;
    }

The ReadMessageCommand class is the following.

    class ReadMessageCommand implements CommandInterface {
      protected $message;
      // Constructs a ReadMessageCommand object.
      public function __construct($message,$level) {
      $this->message = $message;
      $this->level = $level;
      }
     // Implements Drupal\Core\Ajax\CommandInterface:render().
    public function render() {
       return array(
      'command' => 'readMessage',
      'message' => $this->message,
      'level' => $this->level,
     );
   }
  }

I include a JavaScript file.

    (function($, Drupal) {
      Drupal.AjaxCommands.prototype.readMessage = function(ajax, response, status){
      $('#edit-field-region-management-'+response.level+'-valueregion').val(response.message);
     };
    })(jQuery, Drupal);

The controller class is the following.

   class AjaxCommandsAddController extends ControllerBase {
     public function messagesPage() {
       $page[] = array(
         '#type' => 'markup',
         '#markup' => $content,
     );
// Attach JavaScript library.
       $page['#attached']['library'][] = wms_ajax_commands/wms_ajax_commands.commands';
       return $page;
      }
    }

But when executing, I get the following error.

  Fatal error: Class 'Drupal\Core\Ajax\ReadMessageCommand' not found in Path-to-module/src/Plugin/Field/FieldWidget/RegionWidgetType.php


texts: Defining a constant via a function provided by another module?

texts:
In my custom module I want to define a constant which takes its value from a function provided by another module. When I call this function in my module I get a 'call to undefined function' error. Curiously, if I call the function from inside another function, I don't get an error and it works fine. It's as if all module functions get loaded at the same time and then executed, but anything that is not a function gets executed first before the functions become available.

// MY_MODULE.module

$var = FUNCTION_FROM_OTHER_MODULE();
define('MY_CONSTANT', $var);

// use MY_CONSTANT in the other hooks and functions of MY_MODULE

Why am I getting this error and how can I set my constant with this function? Hope this makes sense. thanks.


texts: Get created term entity after creating term programatically

texts:
I'm writing a custom Drupal Console command to import user data from a text file and create users, and as part of the process, I need to add data to a term reference field. In the case that a term in the data doesn't exist, I need to create the term and then add the new tid to the the field. I'm using the following code to create the term:

$term = Term::create([
  'name' => $member[$roster_key],
  'vid' => 'topic_area',
])->save();

The problem is the save() method only returns a boolean indicating if the save was successful, NOT the created term object. This means that now that my term has been created, I have to go do an entity query just to get the object I just created.

Is there a simple way to get the just-created term in my code above, or do I really have to do a separate query?


texts: file_entity update means views now checks for public: in their uri?

texts:
Since a recent update, I think Views must have changed the way it links in relationships to file fields.

Now the SQL includes a WHERE clause like this:

EXISTS (
  SELECT fm_access.fid AS fid
  FROM file_managed fm_access
  WHERE ( (fm_access.uri LIKE 'public%' ESCAPE '\\') ) AND
  (file_managed_field_data_field_file_private.fid = fm_access.fid) )

Now the files that are linked here are actually private, so this clause means my view now returns nothing.

Why is Views adding this bit, and how can I stop it from doing so?


texts: How to make all webform types collapsed by default?

texts:
I just installed a Weboform Conditional module as per @PreritMohan recommendation.

Is there a way to make Textfield, textarea, select option, email, number, date, file types Collapsed by Default ?

I am running Drupal 7.19, webform 7.x-3.18 and webform_conditional 7.x-1.0-beta1

Also, what values should I put in the Options text area? (Key-value pairs MUST be specified as "safe_key|Some readable option". Use of only alphanumeric characters and underscores is recommended in keys. One option per line. Option groups may be specified with . <> can be used to insert items at the root of the menu after specifying a group.)

SImilarly, what should I put in the Values field under the Conditional Rules section? (List values, one per line, that will trigger this action. If you leave this blank, this component will always display.)


texts:
I've made a custom module for Drupal 6 that has a custom form, which works perfectly.

I've tried to add the form in a block using the following code.

function mymodule_block($op = 'list', $delta = 0, $edit = array()) {
    switch ($op) {
       case 'list':
          $blocks[0]['info'] = t('BLOCK INFO');
          return $blocks;
       case 'view':
          $blocks['content'] = drupal_get_form('mymodule_form');
          return $blocks;
   }
}

I can see the block in the admin page, and I can move the block to the different regions and everything seems to work, except for a list of warnings I get every time I change the region of the block.

  warning: Illegal string offset 'region' in block\block.admin.inc on line 101.
  warning: Illegal string offset 'status' in block\block.admin.inc on line 101.
  warning: Illegal string offset 'status' in block\block.admin.inc on line 102.
  warning: Illegal string offset 'weight' in block\block.admin.inc on line 103.

How can I fix these warnings?

I think these warnings happen because block.admin.inc is trying to access a non existent key ("region", "status"...etc). How can I remove said warnings? I have looked into some threads but their solutions have not worked for me.


texts: Add views exposed filter programmatically

texts:
I used the below code in hook_views_pre_view to add two exposed filter to a view, the first filter which provides available brand works perfectly but the second filter is not added at all, no error is logged though, any help on that?

  $available_brands = dpspec_get_available_brand_name($mid);

  $filter_options = array(
    'value' => $available_brands,
    'exposed' => TRUE,
    'reduce_duplicates' => TRUE,
    'type' => 'select',
    'required' => FALSE,
    'expose' => array(
      'operator_id' => 'field_brand_op',
      'label' => t('Brand'),
      'operator' => 'field_brand_op',
      'identifier' => 'sp_brand',
      'reduce' => TRUE,
      'vocabulary' => 'tags',
      'multiple' => TRUE,
    ),
  );
  $view->add_item($view->current_display, 'filter', 'field_data_field_brand', 'field_brand_tid', $filter_options);

  $available_colors = dpspec_get_available_color_names($mid);
  $options = array(
    'value' => $available_colors,
    'exposed' => TRUE,
    'reduce_duplicates' => TRUE,
    'type' => 'select',
    'required' => FALSE,
    'expose' => array(
      'operator_id' => 'field_color_op',
      'label' => t('color'),
      'operator' => 'field_color_op',
      'identifier' => 'sp_color',
      'reduce' => TRUE,
      'vocabulary' => 'tags',
      'multiple' => TRUE,
    ),
  );

  $view->add_item($view->current_display, 'filter', 'field_data_field_color', 'field_color_tid', $options);


texts: Disabled date field on node form stops it from saving

texts:
I have a date field on a drupal node edit form using the pop-up calendar widget. When certain things happen on my site I have to disable some fields on that node edit form, including the date.

However, when this happens, I can no longer save the form because I get this message:

  The value input for field [my field] is invalid.

I tried changing the widget to plain text, and it works fine, so it is an issue with the pop-up calendar widget.

Any ideas?


texts: Template conditional based on a list field

texts:
I have a 'List (text)' field set up with five options displayed as a series of checkboxes.

I would like the last of these checkboxes to control the visibility of a button in the node template.

<?php if($node->field_the_checkbox_field['und'][0]['value'] == 'key_of_checkbox'): ?>
    // do stuff
<?php endif; ?>

The problem with the above is that it only works when this checkbox is the only one selected, otherwise it is no longer the '[0]' result.

How could I go about checking all of the potential five checkboxes for my result?

Thanks!

EDIT

I thought I'd found a horribly verbose workaround by checking every offset one by one like so:

<?php if($node->field_the_checkbox_field['und'][0]['value'] == 'key_of_checkbox'
    || $node->field_the_checkbox_field['und'][1]['value'] == 'key_of_checkbox'
    || $node->field_the_checkbox_field['und'][2]['value'] == 'key_of_checkbox'): ?>
        // do stuff
<?php endif; ?>

etc... but, now I get an 'undefined offset' error for each offset that doesn't exist, ie. not all of the boxes will ever be checked, and so there are never usually five results, meaning that when only two of these checkboxes are checked offsets 2 - 4 don't exist. PHP doesn't like that, apparently.

I'm wondering if my problem here is that I should be using five boolean checkboxes, which at least will always return a result one way or another. That seemed messy when I was planning this out, but now it's looking ever more inviting!

EDIT 2

Since I'm short on time, I decided to go with my thoughts above and base my conditionals on single points of data which can either return me a 'true' or 'false' status. My PHP (as you can probably see above) is crappy to say the least - far too crappy to work out how to get around this one. I'd be interested if anyone has any ideas regarding this though!

Thanks for reading.

EXTRA EDITS for clarity and grammar


texts: Is Drupal suitable for that kind of ecommerce?

texts:
I have to do website that sells webinars and I want to use D7 to this job. Unfortunately I have never done any Drupal ecommerce before.

I'll have to kind of users:

Teacher
Student

Payment method: PayPal only

Webinar content type:

Title
Description
Start date (every webinar length is 60 minutes)
Places
Price is the same of all webinars and is specified by Admin
Webinar booked at least 7 days before start costa less (discount and days limit  configurated via admin area)
If a webinar is cancelled need option to move the participants/users into a new webinar

User of role Teacher can add/edit/list his Webinars.

In addition Teacher can create group with fields:

Topic
Description
When Teacher is creating new webinar, he can specify group for this webinar (select list) (not mandatory)

Student (auth user) can buy single webinar or group. When buying group discount is bigger.

Every webinar can repeat and has multiple start date. Setting next start date must generate different ID for webinar for invoice

If do it by plain PHP database structure will look something like:

groups

id
topic
title

webinar

id
group_id
title
description
etc

webinar_date

id
invoice_id (maybe webinar id + webinar_date id)
webinar_id
date

Teacher can see list of his webinar with dates, so if webinar has two dates it must be visible in two times in list. Also info about free places of webinar must be and income from bookings of webinar. After choosing webinar Teacher can see list of all users that buy webinar 'ticket'.

The same is for admin but he can see all webinars of course.

Is this possible to create in Drupal without a lot of pain?

Which module are most suitable for this: Commerce or Ubercart?

Thanks in advance


texts: Is there a REST endpoint for getting the logout token?

texts:
So I know the logout_token is generated along with the csfr_token during the POST to /user/login?_format=json.

You can get a copy of the csfr_token for the session at any time by calling a GET on /session/token. Is there a way to get the logout token outside of the user logging in? So is there a path that once logged in will provide you with the logout_token? I'm looking for a way to clear a cookie that gets stored beyond the initial session.


texts: I'm migrating a large custom module and theme from Drupal 6 and can't work out how to convert references to $node->body and $node->teaser since they are no longer fields in the node object, right?


texts: I customised the output of a field (using Rewrite the output of this field) but if the field is empty, only the customizations and not the content appears. I want to hide both the customizations and the content if the field is empty


texts:
I have to migrate a website from Drupal 7 to Drupal 9.
My Drupal 7 files were located in this directory : sites/mywebsite/files
In Drupal 9, files will be located in this directory : sites/default/files
While paths are automatically managed by media module in ckeditor in D9, the path for every file is still sites/mywebsite/files/myfile.pdf. I don't know where to change it.
How to fix this?
Thanks


texts: bookmark organize for anonymous user permission

texts:
I have use drupal 7. I download and install the flag , flag bookmark, bookmark module.I have also add settings for bookmark. Bookmark functionality is work for authenticated and admin user. i wanna functionality for anonymous user. So how can I use for anonymous user ?

I have check the permission but they can't provide the permission for anonymous user.

so can you explain me how can I do this task ?


texts: Theme Suggestion for overridding page-title.html.twig file?

texts:
Is there a way to override the default page-title template using the theme suggestion. Like we can override node for article type as below,

For all nodes:    node.html.twig

For nodes of article type:    node--article.html.twig

same way,

for all page title: page-title.html.twig

for page title on article content type: ???

I tried many things like page-title--article.twig, field--page-title--article.html.twig, field--bartik-page-title--article.html.twig, node--article--page-title.html.twig etc.. these are not working. OR it is not possibel to do this with page-title file?


texts:
Recently I created two pages for http 403 and 404 and assigned them so that on error those two will be shown.
But today when I tried to login to my admin in my site: http://www.indiacustomercare.com/admin
it is giving error "Error 403 - Permission Denied".

The message:"Unfortunately the page you are looking for is not accessible by you." is from the page I had assigned for http 403.

Looks like I did some silly mistake, my other two D6 sites have no problem logging in.

How do I login into admin again?


texts: White screen of Death after clearing cache, can't find a way to get the site back up

texts:
My problem is that I keep getting the white screen of Death ever since I cleared the cache of my Drupal website.

The error is the following :

PHP Fatal error:  Call to undefined function uc_address_property_info() in
sites/all/modules/ubercart/shipping/uc_shipping/uc_shipping.rules.inc on line 12

It happened after I cleared all the cache using the button from the Drupal configuration page. I'm pretty sure the Ubercart Store module is enabled, and I tried clearing the cache from the database already. Before clearing the cache, the site was working fine. The only thing I did is trying to hide some profile2 fields that I created and since they were still there, I thought that clearing the cache would do the trick.


texts: Trying to add a shipping calculation rule using "Order Address component comparison" condition

texts:
I'm attempting to create a basic "Shipping rate by country" Calculation rule in Drupal Commerce using the Flat Rate shipping module.
I've followed the official tutorial for this exact thing (here) but run into a problem when I attempt to add the "Order address component comparison" Condition. I simply get a "No order addresses could be found for comparison." error and the Address dropdown is empty (see screenshot below).
I've been unable to find any references to this error. I added Commerce to an existing Drupal 7 site so I'm wondering if I missed a piece of configuration somewhere. Other than that every other aspect of the store runs fine.


texts: I would like to create a page that will automatically forward to an external site? Similar to what bitly, tinyurl do. So when people type example.com/page in address bar, site will automatically take them to mysite.com? How can I achieve that?


texts: How to deal with login attempts coming from 1-127.0.01 and what does it means?

texts: Recently on my drupal 7 site happens that i find the admin account blocked. Looking to the flood table i see a lot of failed login attempts from ip "1-127.0.0.1". It's an external attack or something not working in my site? The fact that the ip the request comes from is 'localhost' is confusing me. In both cases, how to deal with this problem?


texts: Drupal 7.12: content type select widget not working

texts:
for some reason i cannot select a widget when adding fields in my content types.

when i select a 'type of data to store', it automatically populates the form element section but i cannot change the option nor can i save the field. Has Anyone faced this problem before?


texts: How to automatically create nodes according to related content types?

texts:
I am very new to Drupal. I have a situation where I have 3 content types, say A, B, C.

For each node instance of type A, there should be 3 corresponding nodes instances of type B. And for each instance of type B, there should be 5 corresponding nodes instances of type C. So in total 1 + 3 + 15 = 19 nodes.

Is it possible to automatically create the B and C node instances when the A node is created? And it is automatically possible to delete them if A is deleted? In other words, I would like to create tree-like instances of nodes.

Is this possible in Drupal? Is there a module for this, assuming I am creating the 3 content types A, B and C? Alternative solutions/ideas are welcome too.


texts:
I am trying to create a configuration form for my test Drupal 8 module. I have followed the instructions from the following tutorials:

https://www.drupal.org/docs/8/api/configuration-api/working-with-configuration-forms
https://www.drupal.org/docs/8/api/form-api/configformbase-with-simple-configuration-api

Before I followed the instructions in these guides my module worked fine. However, after adding the form, I now get a WSOD when installing the module, with no error in the logs. I know that error reporting is on because I can make intentional mistakes in my module files and an error will be reported in the logs.

My question is: where have I gone wrong? It's hard to figure out a problem when you don't even have a stack trace to follow.

My company_info.routing.yml file:

company_info.content:
  path: '/company_info'
  defaults:
    _controller: '\Drupal\company_info\Controller\AdminController::content'
    _title: 'Hello World'
  requirements:
    _permission: 'access content'

company_info.admin_settings:
  path: '/admin/config/company_info'
  defaults:
    _form: '\Drupal\company_info\Form\AdminSettingsForm'
    _title: 'example'
  requirements:
    _permission: 'administer site configuration'

AdminSettingsForm.php:

<?php

namespace Drupal\company_info\Controller;

use Drupal\Core\Form\ConfigFormBase;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormStateInterface;

class AdminSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'company_info_admin_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function getEditableConfigNames() {
    return [
      'company_info.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state,
Request $request = NULL) {
    $config = $this->config('company_info.settings');

    $form['your_message'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Your Message!'),
      '#default_value' => $config->get('your_message'),
    );

    return parent::buildForm($form, $form_state);
  }

  /**
   *
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->config('company_info.settings')
      ->set('your_message', $form_state->getValues('your_message'))
      ->save();

  }
}

company_info.settings.yml

your_message: 'Default message here'


texts: I am using Drupal 6 with the Open Atrium distribution. Is there a problem if the same user connects from more than 100 different computers at the same time? At the moment I am unable to do a test but I would like to know if I can encounter any problem. So far I did try with 10 PCs and no problem whatsoever. Also is there a limit that I have to remove or by default there is no limit? Thank you.


texts: I created a form using Entityform module. I'm not able to translate name of entity form type. How is it possible to translate name for each enabled language?


texts: How do you create a custom page layout in Drupal 8? In drupal 7 you could do something like page--about.tpl or something. How do we do that in drupal 8?


texts:
I would like to know how to get parent terms only, for example "Ages 0-2" and also print in dropdown.

This is the structure of the form array.

Array(
  [#info] => Array(
    [filter-tid] => Array(
      [operator] => tid_op
      [value] => tid
      [label] => Term
      [description] =>
    )
  )
  [tid] => Array(
    [#type] => select
    [#options] => Array(
      [All] => - Any -
      [0] => stdClass Object(
        [option] => Array(
          [367] => Ages 0-2
        )
      )
      [1] => stdClass Object(
        [option] => Array(
          [2378] => -Infant
        )
      )
    )
  )
)

This is the code I am using.

  if ($form['#id']== "views-exposed-form-quick-find") {
    $test = $form['tid']['#options'];
    foreach ($test as $tid) {
      // It prints "Array" and the "Trying to get property of non-object" message.
      print $tid->option;
    }
  }

I do not understand why the "Array" text repeats; it could be I am not pointing to right array.

How do I remove all children which do not have "age 12 - 14" (see "-" in the middle not from start)?


texts: How to get change event working of a taxonomy select box on a node form?

texts:
I have a taxonomy, which I have added to a content type. Now a select box from the taxonomy appears when I want to create a node of that content type.

That content type have a cck field of type select.

In my module in the hook_form_alter I want to execute the js change event of the taxonomy select box, but it does not work.
And when I try to execute the js change event on cck select box, it works fine.

here is my code.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
     if($form_id == 'contenttype_node_form') {
        drupal_add_js("
            $('#taxonomy-select-box-id').change(function(){
                alert('change');
           }) ;

", "inline");
    }


texts: Book navigation that expands to child page from a non-linked header

texts:
I have a site with many books, some of them fairly large. I have it set up so that there is a book navigation block on the right hand side of the page. I want to be able to expand the navigation block to enable child pages to be viewed. However, the parent page of the children does not have content in it. Thus, it seems silly to have to click and empty page, wait for the browser to refresh, just so I can view children pages, so I can click again to get the child pages. It is a very disjointed experience for a user.

I am looking for a solution that can look something like this:

Top book page
P1
P2 (<-- this page has no content, it is a header that describes the kinds of pages below)
-1 child of p2
-2 child of p2
-3 child of P2
P3
P4

In this case, clicking P2 would expand its children, but not navigate away from whatever page you are on. Preferably, this would be a solution that I could implement site-wide, rather than perform individually for every single book (there are many books, and they will be updated periodically, so a automated solution is obviously ideal).

I am currently having difficulty understand why no-one else (to my knowledge) has had this difficulty, or why there are no contributed modules to help with this. Perhaps I am missing something obvious.

I am using Drupal 7.

Any help would be greatly appreciated!


texts: How to change position & amount of fields in content type dynamically (means by editors)

texts:
I have a content-type, that can be structured like this:

content-type A

title
summary

part one title
image
text

part two title
image
image
image
text
image

part three title
text
image
text

I have no control about the position and the amount of elements that can occur. I just have the types, like heading, text, image. Actually i have only fields or rather field-groups.

How can i give the editors the possibilty to move these fields or field groups inside the content type so they can determine the position? Is there something like nodequeue for fields?

Or should i alternatively cut the content-type to smaller pieces and organize it with nodequeue? I haven't worked with nodequeue before, is it possible to give a queue a menu-entry for example?

edit: Just before i asked my question i was watching a tutorial of Display Suite and if i understood correctly i can change the layout of a content-type globally. I'm looking for a solution that gives more control over each "article" created with a content-type. Maybe i was unprecise in my question...?


texts: How to add Title attribute to Menu links?

texts: Is it possible to add Title attribute to Menu items? If so, how?


texts: How to retrieve a file via REST from the services module?

texts:
Which URL format should I use when retrieving a file via the services module?
I figured that it would be formatted like this:

http://<domain>/<endpoint>/file/fid

I've tried several file ids but all I get is an empty result.   Is this the correct url format for retrieving a file?

Services module version is 3.


texts: How Does Pathauto for Drupal 8.x Determine Generate URL Status?

texts: I would like to turn off the "Generate Automatic URL Alias" for all existing content in my Drupal 8 instance. How do I do that? According to this thread D7 used a table: pathauto_state. From what I can see there is no pathauto_state table in the D8 database. After migrating a website from D6 to D8 with many carefully crafted URL aliases every node is now set to "Generate automatic URL alias" by default. So every time a user edits some old content and saves, the auto-generator kicks in and blows away the old alias unless the user remembers to untick the box. I desperately need to set the "Generate automatic URL alias" to FALSE for all existing content either through the GUI or else through MySQL statements or some other method. Can anyone please advise?


texts: Merge users between multiple installations?

texts:
I'm faced with a particularly tricky task.

I currently have a public facing website with a user base.  I have a few custom fields attached to the users for things like first and last names.

Now, I have an intranet site as well.  I wish to sync the users from the public facing website (PFW) to the intranet site.  I have to copy more than just the custom fields, I also have to make sure that the unique IDs for each user are the same in the intranet site as they are in the PFW.  How can/should this be done?

EDIT: I should mention that the users that already exist in my intranet database are just test users - they can be destroyed.


texts: How do I display images from a field in a View as grid?

texts:
I have a view that displays images from an image field of a specific node and I want to display those images in a grid but Views groups them together so the whole node is put into the grid cell instead of each image separately.

How can I make such View?


texts: Webform Drupal 8, node and form, how to pass node field info to form?

texts: I don't understand how node integration with webform works.  How do I pass data from a node with a webform field to an instance of that form?  I created a form with email and location.  Then I created a content type with location, description, date, and a webform field and then I added some content to it. How do I associate the location from the content type to an instance of a form?  How does the "Default submission data (YAML)" work?  I put "[current-page:title]" in there expecting it to populate the form, but I don't understand how to specify what form field it goes to or if I'm using the right syntax or what??


texts: How can I disable a form's default validation functions?

texts:
I have created my own validate handler:

/**
 * Validate handler.
 */
function my_module_validate($form, &$form_state) {
  $values = $form_state['values'];
  if ($values['type'] == 'line') {
    form_set_error('type', t('MY VALIDATION.'));
  }
}

which is called from a button element:

'preview' => array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#validate' => array('my_module_validate'),
  '#weight' => 8,
),

which produces this result on submission of an empty form:

The only validation function that I want to run is my own, from my own handler - the last error message - yet all the default validation functions run as well. How do I disable these?

Thanks.

UPDATE:

The solution provided by @superdrupal looks 'correct', but I cannot get it to work. Here's my code:

'map' => array(
  '#type' => 'select',
  '#title' => t('Map'),
  '#required' => TRUE,
  '#options' => array(
    'map1' => t('Map 1'),
    'map2' => t('Map 2'),
  ),
  '#element_validate' => array('my_module_map_validate'),
),

...

// Buttons/link.
'preview' => array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#limit_validation_errors' => array(array('map')),
),

...

/**
 * Map validate handler.
 */
function my_module_map_validate($element, &$form_state, $form) {
  drupal_set_message('Hello world!');
  if (empty($element['#value'])) {
    form_error($element, t('xyz'));
  }
}

which, rather than throwing the error: 'xyz' on submussion of an empty form, produces this result:


texts: Facet API - All available Facets in one Block or on one Page

texts:
I need to create a page where all values of all fields of a content type are listed. All of these fields are list/text - fields. Behind these listed items I need to print a counter, that counts how many nodes have a certain value. Preferably I would love to do that with views, using aggregation seems not to work and even if it would performance would be the next problem. Trying to use other base-tables playing around with data-module but until now best I could find was https://www.drupal.org/project/searchapimultiaggregate.

For background: Intention is to get some kind of result-summary of statistical data. I know modules like quiz, webform, entityform or even the limequery integration which would perfectly do what is needed, but mainly because all data is already in the nodes, this seems no way to go.


texts: Location's Distance/Proximity exposed filter without Node Location Submodule but with Location CCK Submodule instead

texts:
I would like to stay a little bit more flexible and use Location CCK fields (from Location CCK Submodule) instead of Node Locations (from Node Locations submodule) on my nodes. However, in my view of nodes the "distance/proximity" exposed filter (distance from a user-entered zip code) only works when my nodes have a location attached to them via Node Locations Submodule. If I disable Node Locations Submodule and attach a location to my nodes via a Location CCK field, the "distance/proximity" exposed filter never returns any results.

Does anyone know how to get around this issue?

Best,
deinqwertz


texts: How to alter 'not null' value of field after creation

texts:
I have a custom module that defines a field wherein I erroneously set the 'not null' value to be FALSE when I should have set it to TRUE. Ideally I would like to remedy this by means of an update hook. How can I do that?

function MYMODULE_field_schema($field) {
  $columns = array(
    'payments' => array(
      'type' => 'varchar',
      'length' => 20,
      'not null' => FALSE,
      'description' => 'Number of payments made',
    ),
  );
  return array('columns' => $columns);
}

From reading the documentation it looks like I could do it by passing a field structure to field_update_field, but I don't know what to put in the field structure

function MYOTHERMODULE_update_70xx() {

 $field = array(
    // What should I put in here in order to change 'not null' to FALSE
    // and as a bonus, change the type from 'varchar'
    // to an integer (number_integer?)
);

 field_update_field($field);
}

Am I over-simplifying things? I know it's often not possible to modify fields if they contain data, and in this particular case I can delete and re-create the content type without too much difficulty, but no point doing all of that if there's no need.


texts: How to replace usage of static Entity::load method calls for better testability?

texts:
In my method that I'm testing in UnitTestCase based class I have a statement:

Term::load(self::HARDCODED_TID);

Any other way to load Term object to make it 'mockable'?


texts:
In Global redirect "Add Canonical Link" and "Set Content Location Header" are off by default.

I am not sure should i turn them on or not.

I have community website with around 5000 nodes.
In webmaster tools i don't have any errors.


texts: Run a boolean test function on form submit

texts:
Is there a way to run a function when a user submits a form in Drupal that returns a true or false. If it is true, run the submission handler. If false, return an error.

Application:

I am using Drupal to run a product booking system. If a product is reserved during a certain period of time, it is not available to others. The client wants the customer to be able to change the dates of the their order. This is fine. The order creates a reservation node and with permissions and hook_form_alter, I set it up so that they can edit the reservation dates.

However, I don't want them to be able to change the dates to whatever they want without first checking to see if it is already reserved. I have already written the code to run a query and return a boolean based on whether or not there is a booking conflict. Now I just need to be able to use that on the form submission handler.


texts:
Our Drupal 7 site has a feed of events which are parsed into nodes. Not every event is equally relevant, and they would like a way to selecrt the top five events, sorted chronologically, to appear on a block on the frontpage. They would also like the events to no longer display in the block once the event has passed. They are comfortable using Nodequeues and have requested one be created for this functionality. So far, this is pretty basic stuff and I have created a View which accomplishes this. The tricky part happens when there are less than five upcoming events in the queue. In this case, they would like unselected events to fill out any vacancies in the block of five.

Typically when I create a Nodequeue:

I create a relationship to the queue
I sort by position in the queue
I filter that the event is in the queue.

By removing the sort and filter, and instead sort first by if event is in queue and then by event date, I get the content I desire; when more than five events are selected, it works fine. When no events are selected, it works fine, however when there is a mix; naturally the in queue events are listed first. I would like all five events to be sorted chronologically.

An aside, I'm not certain Nodequeue is even the best way to do this; as the position in the queue implies a hierarchy. A flag could mark selected nodes, or a boolean field on the content type, or a taxonomy term might each be better solutions. I'm open to suggestions.

But first, how can I best properly sort this list?


texts:
I have been running into some trouble with displaying Field Collections. I have a content type (products) that has a field collection called packages. Randomly I would notice that sometimes the field collection fields wouldn't display. Today they have stopped displaying and aren't coming back.

I can't seem to figure out what the issue is. All the fields are set to display in the field collection display settings. Even when I just look at the node view page they aren't displayed there.

I was curious if anyone can help with this issue?

EDIT: It appears that enabling and disabling modules (doesn't matter which one) fixes this and the fields display. Not sure what triggers it to break again though.


texts: Using config split to keep dev modules separate: how to manage enabled/disabled states?

texts:
I'm using the config split documentation to exclude dev module configuration on my site.

I made a configuration split that blacklists the following modules:

Devel
Kint
Field UI
Menu UI
Views UI

I then edited settings.php so that this config split is active on my dev environment but not my test or prod environments:

  elseif ($_ENV['PANTHEON_ENVIRONMENT'] === 'dev') {
    // Enable dev modules.
    $config['config_split.config_split.dev']['status'] = TRUE;

In the UI (/admin/config/development/configuration/config-split), the Status of the config split on the dev env is active (overwritten).

However, when I close the database from live and run drush cim on dev, the dev modules are not installed,

I am guessing this is because config/core.extension has the dev modules disabled.  However, I want them disabled in this file because if they are enabled, the modules will also be enabled on production.  So what am I supposed to do to get the dev modules imported on dev?

If I log in as an administrator and change the config split to TRUE in the UI, then run drush cim, the dev modules will be enabled.  However, when I run drush cim again, the dev modules will be uninstalled again, so this doesn't work, either.

The documentation says: These settings need a cache clear when overridden in settings.php and the split needs to be single imported before the config import for new values to take effect.

I did the cache clear, but I don't know how to single import the config with Drush.


texts: How to remove inner div from create block in drupal 7

texts:
Here, i struggling to remove inner div from create block in drupal 7.Here my working code with wrong result:

<?php  if($page['footer_bottom_left']){ print render($page['footer_bottom_left']);} ?>

  <?php  if($page['footer_bottom_left']){ print render($page['footer_bottom_right']);} ?>

I used string_tags before render it remove entire html tags. But i need to remove only block div and content div.Here my wrong result:

Plan du site

Acessibilite

Credits

Mentions legales

Correct format:

Plan du site

Acessibilite

Credits

Mentions legales

How to remove inner div from custom block in drupal 7.Kindly guide me..?


texts: Build a hierarchical menu with multiple nodes location

texts:
I look for one (or more) module (s) to allow me to have an organization such as in Drupal 7 :

A node can be in one or more section of the menu
It will have its own URL to reach each of its sections and we keep the section when one consults
and so own breadcrumb by location
the node are not necessarily display in the menu, we can see the node when we are displaying the section, not directly in the menu.

example:

section 1

section 1.1
section 1.2 ( contains 2 nodes related : node 1 , node 2
)

section 1.2.1 ( contains 1 node related : node 4)

section 2

section 2.1 (contains 2 nodes related : node 2, node 3)
section 2.2

When I click to this link section 1.2 (URL :  /section1/section1-2 )

We display : node 1, node 2, section 1.2.1 ( display : teaser )
each teaser have a specific link :

/section1/section1-2/node1
/section1/section1-2/node2
/section1/section1-2/section1-2-1

The node 4 in section 1.2.1 isn't displayed.

When I click to this link section 2.1 (URL : /section2/section2-1)

We display : node 2, node 3( display : teaser )
each teaser have a specific link :

/section2/section2-1/node2
/section2/section2-1/node3

So we have same content in two locations : /section2/section2-1/node2 , /section1/section1-2/node2

The menu and breadcrumb must remain the current path

If we are in : /section2/section2-1/node2

The section 2 , section 2-1 menu are active

The breadcrumb are section2 / section2.1

I try to use taxonomy menu to achieve but it seems that we can't have multiple locations for node.


texts: On the 404 page, look for an XML file and read it in. If it doesn't exist, display 404 message

texts:
I am wondered if the following is possible: I need to display some XML data on the fly; these should only be created temporarily (ie not nodes or entries in a database and therefore not readable by Google). The URLs for these and the other XML files I import into nodes have the same structure, generated by a third-party system; so I need the page to be generated if the node doesn't exist (so I guess on the 404 page you will be redirected to).

I thought something like this might work. Any pointers?

<?php
  $hdr = $_SERVER['HTTP_REFERER']; //Format of http://example.com/item/######
  $idnr =  substr($hdr, -6);
  $file = simplexml_load_file('http://api.service.com/customerID/item/'.$idnr);

  if (file_exists($file)) {
    // Put my XML fields here.
  } else {
    //Echo 404 message
  }
?>

EDIT After reading Alfred Armstrong's and develkar's answers I guess what I could think about is something like this: In the module_menu callback function: Look for a node with that URL alias. If that doesn't exist, load the XML. If THAT doesn't exist, return a 404.


texts: Is it possible to create a pre-filled select list field with Drush?

texts:
The syntax to create fields is on https://drushcommands.com/drush-8x/field/field-create/

For those it works:

Images:

drush field-create article img,image,image_image

Text fields:

drush field-create user address,text,text_textfield --entity_type=user

text long:

drush field-create user address,text_long,text_textarea --entity_type=user

Decimal:

drush field-create user userpoints,number_decimal,number_textfield --entity_type=user

Boolean:

drush field-create content haspurchase,list_boolean

Is there a way to create a select list field pre-filled with values?


texts: Combined Fields filters and missing custom search api fields

texts:
Drupal 8

I am using Search API and Views to search several fields from several content and media types. For example, I have a custom "description" field for Media->files so users can add a searchable summary field to pdfs they upload to a website.

While I can get it set up to search all the fields using exposed filters and an "OR" filter grouping, this leads to an exposed filter for each field... which is not ideal. I would rather a single input box that allows several search terms to be passed to each of the filters.

I have tried to use combined field filter however it is missing a number of the fields passed from the Search API index. For example, below is a simple example searching only pdfs with a custom description field.

Media type and Name are available but not Description or even filename. Is there a way to make these available in the combined filter?

Any other method to achieve the desired result of a single search box for multiple filters would also useful. Just to re-iterate. The filters work, I just want them in a single search field.


texts: How would I override misc/ui/jquery.ui.theme.css

texts:
I have theming being automatically applied by misc/jquery.ui.theme.css that I need to modify. I am using Views Accordian plugin in an instance of EVA for a FAQ category.

What is the Drupal way to override some of the css in this instance?

I read the "How to override a theme function?" but I don't think it would work in this case, I could be wrong.


texts: Import Feeds module & Tamper in combination with atypical csv file

texts:
I'm trying to do an import from a csv file using Feed Import & Feeds Tamper modules. I'm in a bit over my head though. The feed I need to import uses an atypical format. Instead of having a traditional header attached to each column, the header content is pertinent to each content imported. For instance the header will contain content specific to each row from my csv. I'm trying to avoid modifying the content each time before I import it if possible. Does anyone have any suggestions how I can get the header content added to each specific row of content from the csv? CSV content is as follows.

(row 1)  A     JC   2450    5/11/2015   5021
(row 2) C2111   3   327     340
(row 3) C2111   4   330     345
(row 4) C2111   5   338     332.5
(row 5) C2111   7   392     315


texts:
Is it possible to disable CSS and Javascript aggregation by role?

That way during content editiong or administration stages the user is not affected and can check the CSS alright, while end users received cache values as usual. If the cache lifetimes are long enough the editing can be completed before it any changes interfere with the other users.


texts: How to call template when Custom form is submitted?

texts:
I have created custom form and on submit of that form, I need to fetch data from database and need to display that content in well structured format in different template.

I am able to create form, on submission, I am able to fetch data from database but I am not able to pass that result to another template and display data on that template. I have also tried with

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

  $items['form-example'] = array(
    'title' => 'Example Form',
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('nexposed_form'),
    'access callback' => TRUE
  );
  return $items;
}

function nexposed_form($form, &$form_state) {
  $toppings = array(
    'Jan' => t('Jan'),
    'Feb' => t('Feb'),
    'Mar' => t('Mar')
  );

  $form['month'] = array(
    '#title' => t('Months'),
    '#type' => 'checkboxes',
    '#description' => t('Select the Month'),
    '#options' => $toppings,
  );
  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Click Here!'),
  );

  return $form;
}

function nexposed_form_validate($form, &$form_state) {
}

function nexposed_form_submit($form, &$form_state) {
  drupal_set_message(t('Search submitted successfully.'));
  $query = db_select('node', 'node');
  $query = $query->fields('node', array('nid', 'title'));
  $query->condition('node.type', 'events');
  $rows = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

  return theme('event_page', array('data' => $result, 'paging' => $paging));
}

Where $result contains data in the key value pair format, but that template is not called rather no result is displayed.

Any help regarding this is highly appreciated. Thanks in advance.


texts: Add block fields as contextual filter in view

texts:
Is it possible to add field from block into contextual filter?

There is a custom block listed on front page containing three drop down select list fields depending to one another.

  First field contains taxonomy parent term.
  Second field contains child term depends on above selected value.

I also have another block of view showing all the node titles having selected taxonomy term. Now my problem is that how can I add two fields(parent & child term fields) from first block as contextual filter in view.
Note that first block is a custom block developed in a custom module while the second block is a block in views.
So how is it possible? Anyone help?


texts: After selecting "My billing information is the same...." an Edit button is shown

texts:
QQ - When registered user goes through their cart to their payment information the "My billing information is the same as my shipping information. - Optional" is shown as default checked.
When they uncheck this box an Edit button appears. Is there any way to stop the edit button from appearing and simply show the fields? This happens when the user has NO address stored. So it's not very intuitive what the next step is.

In the CSS, on a working site I notice id="shipping-information-wrapper"
On my broken site, that div is not on the page. Instead, this is provided:
<div data-drupal-selector="edit-shipping-information-shipping-profile" id="edit-shipping-information-shipping-profile" class="js-form-wrapper form-wrapper">


texts: I had installed pathauto module and it was generating desired url alias. But now its not working. All the newly created node shows node/node->nid. This issue stops working of my drupal_get_path_alias function i added in views template. Can anyone help me out.


texts:
I have a custom module and a template to alter the appearance of my node submission forms, á la these instructions.

My module consists of three functions:

A hook_form_alter() that works fine
A hook_theme() that doesn't do anything but return an array, even if you enter other code before return (not sure if this is by design)
A hook_preprocess_HOOK() that is currently empty

dpm() doesn't seem to do anything in hook_preprocess_HOOK(), although krumo() on the same variables sort of works. It sets a Drupal message that reads Array: [n] items but can't be expanded or inspected at all.

In my template, print_r($form); prints out the form array as expected. dpm('self-aware roomba'); sets a Drupal message of "self-aware roomba" as expected. but dpm($form); does nothing and throws no error.

Everything except my hook_form_alter() is exactly as it appears in the linked tutorial. I even tried pulling out the entire hook_form_alter() to see if it works without it; it doesn't.

What could be causing dpm()/krumo() to fail silently?


texts: What does combined block caching option 'DRUPAL_CACHE_PER_ROLE|DRUPAL_CACHE_PER_PAGE' do?

texts:
I understand that certain block caching options can be combined. What does it mean if I set the caching option of a block defined in code to DRUPAL_CACHE_PER_ROLE|DRUPAL_CACHE_PER_PAGE?

I am confused by the OR bitwise operator. Does this mean that the block will not only be cached by page, but also by role? For example, if User role A visits the same page as User role B, they will each see different cached versions of the block despite being on the same page?


texts:
I'm trying to integrate Drupal Commerce to a File Maker. Why ? Because my client staffing have been using File Maker for over 15+ years. We are trying to integrate both systems.

So my goal is to be able to send the order information every time a purchase is complete to the File Maker server so they can re-created their order information into File Maker as well.

I started to write my custom module to send the order ID to the File Maker server. Here is how I did it.

/**
 * Implements hook_commerce_checkout_complete().
 */
function commerce_external_call_order_commerce_checkout_complete($order){
  $script_variable = variable_get ('external_script');
  // Combine the URL with the OrderID.
  $final_variable = file_get_contents($script_variable . $order->order_id);

}

And this actually works.

I'm wondering if there is a module that allows me to export my order information every time an order is complete or updated? Ideally would be an integration with Rules and the Service module.


texts: Caching results from an API via drupal_http_request

texts: I need to frequently access a restful API via drupal_http_request. I am doing this in a custom View. Is there anyway to cache this data so that I don't need to as frequently query the servers?


texts:
After creating the node (from a default and custom node) I received the following error,

Fatal error: Call to undefined function creative_customize_comment_form()
  in /home/MYSITE/public_html/includes/form.inc on line 1865

this happens for all users even admin.


texts:
So, I work at a web development agency and we recently decided to give our custom CMS up and start developing with Drupal. Currently, I am developing a wholesale product website. What I need to do is to create some product catalogs without using commerce since we do not need the purchase, checkout and payment features and I thought that using the built-in Content, Taxonomy and Views features we can get our job done.

I have created the product categories in Taxonomy. The main (root) categories are main Taxonomy objects and the subcategories are terms.

I created a custom Content type called: products. In this type I have the following form fields: Product Code, Name, Image, Description and a list field to choose the Terms I would like the product to be displayed in.

I would appreciate some help in order to set the whole structure up as I am still heavily influenced by the custom CMS we used to work on that had similar content management with Joomla!

In conclusion, I would like to:

Set a sidebar menu up that contains the categories and the subcategories as a tree. I would also like the menu to be updated if any changes occur in the taxonomy (e.g I add a term in taxonomy and it shows up on the menu).
Set the structure so that when someone clicks on a category that does NOT contain products but subcategories, gets the list of the categories bellow the active one.

I am really looking forward to your answers and I'd like to thank you in advance.


texts:
I've got an image field, in which I'm showing the image using url by setting the relationship for that field on 'Advanced' tab to get the url of the field.

I'm getting the url of the field as

{% set image = file_url(fields.uri.content|striptags|trim) %}

I would like to know how to get the alt of the image on views-view-fields-view-machine-name.html.twig.


texts: How to rearrange user register form and still pass validation

texts:
I've implemented a hook_form_alter to change order of fields on user registration form. i've moved mail and username fields inside a fieldset. on submit, drupal is returning an error of undefined mail and account index.
How should i handle this? do i create a submit function that defines $form['mail'] = $form['fieldset']['mail']?
Here's my code:
/**
 * Change the elements from registration form
 *
 * @return outputted form
 * @author
 **/

function userreg_form_alter(&$form, &$form_state, $form_id){
    if ($form_id == 'user_register_form'){

        if (current_path() == 'supplier/register'){
            unset($form['profile_main']);

            //move the whole form inside suppliers tab
            $supinfo = $form['account'];
            unset($form['account']);

            $form['profile_supplier']['account'] = $supinfo;

            //add our custom form_validate form to handle what we just changed?

            array_unshift($form['#submit'], 'userreg_form_submit');

        }
    }
}

function userreg_form_submit($form_id, &$form_state){

    $form_state['values']['mail'] = $form_state['profile_supplier']['mail'];

}

The error i'm getting is:

Notice: Undefined index: mail in user_account_form_validate() (line
1264 of /var/www/funa/d/modules/user/user.module).
Notice: Undefined index: account in user_account_form_validate() (line 1265 of /var/www/funa/d/modules/user/user.module).
Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be of the type array, null given,
called in /var/www/funa/d/includes/form.inc on line 2602 and defined
in drupal_array_set_nested_value() (line 6695 of
/var/www/funa/d/includes/common.inc).


texts: Custom layouts with the Display Suite module

texts:
How can I make a custom layout with the Display Suite module in Drupal 8?

I checked the example for Drupal 8, but that didn't work for me.

Could anyone help me?


texts: Ubercart - how to get order information from order ID?

texts:
How to get an object of Order (or something similar - details of an order!) by providing order id? Perhaps, some kind of code like: $order = order_load($orderId);

I'm new to Ubercart (3.x)/Drupal (7.x) and searched the title but found no solutions.

I need to create a view/page by custom module which displays "My Purchases" or "My Sells"

I need to get complete Order details, by providing order-id. Also need the creator/seller and buyer info of the order.

Can someone give me some PHP example/other ways possibly using a View?


texts: Why print $block->content sometimes converts line break to  but sometimes does not?

texts:
During debugging of a sliding animation, I found that print $block->content sometimes convert line breaks to
.

The following code in a block:

  1
  2
  3

is output in HTML as:

  1

  2

  3

Note: there are two
.

While the following code in a block (  surrounded by

):

1

2

3

is output in HTML as:

1

2

3

Note: there is no
.

How can I disable line break to
 conversion when printing block content?


texts:
I have a view and I need to relate contents, the problem is that you do not show me the data.
Two contents: 1. productions, 2. functions (theater).
the functions are related to the productions, but inversely not.

I need to create a cover of productions, which contain the dates of the functions with the link of your purchase.

example:

Manage  Field: functions

products, they have no related field
Thank you very much!

Add a similar problem, on the same types of content.
Is list of productions:

I can not add a list with this design. Add views

thanks


texts:
I need to turn off 404 & related Exceptions. Need to handle it in custom way.

I've implemented an EventSubscriber with listener for kernel.exception event.

But $event->setException() cannot receive NULL.

Any ideas?


texts: Where can I find the save destination path for a filefield? (via code)

texts:
I have an image file field and I am attempting to write a little script that will programmatically scan my nodes and save images found in the body of my node into an image file field entitled field_post_image

I've been looking at the default process of what Drupal 7 + Image Field does and the example on SO found here: https://stackoverflow.com/questions/5129559/attaching-files-to-nodes-programmatically-in-drupal-7

I figured the best practice would be to save the images to the same folder as the file field destination in an effort to keep my /sites/default/files clean of orphaned files etc.

I've looked at both field_info_field and field_info_instance in the Field Info API and I can't seem to find the files destination (as configured in the Field UI)

Am I missing something and/or am I looking in the wrong place?

Thanks!


texts: How to query for a list of tables in a secondary database

texts:
I'm working on some Functional tests on a secondary database. Part of the tear down process is to drop tables in the secondary database. How do a make a query like 'show tables' where I can iterate through them and conditionally drop a table when I want to? I've got a connection to the database, like this:

$conn = Database::getConnection('default', 'civicrm_test');
$database = $conn->getConnectionOptions()['database'];

I was looking at Connection->query() but it doesn't seem to return the results? Is there a different way to get the list of tables so I can return them and act on them individually?


texts: Module Library JS Some In Header Some In Footer

texts:
I have read that Drupal 8 by default loads library-defined files into the footer. My module libraries.yml file makes use of the "header: true" property as several JS files are needed to load in the header. However, now I need to add another JS file to the library, but this new file must load in the footer / just before the closing of the body tag.

How do I modify my libraries.yml file to make this JS file the only footer-loading one?

modulename:
  version: 1.x
  header: TRUE
  js:
    headerfile1.js: {}
    headerfile2.js: {}
    footerfile1.js: {}
  css:
    component:
      css/style.module.css: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupal


texts: entity_load() not listing custom fields.

texts:
I created the custom field for existing entity, I can see those fields listed on 'field_info_instances()' . And I also have data in those fields, but I can't see those fields listed on the entity object returned by  entity_load().

This is how I am installing the fields

/**
 * Implements hook_update_N()
 */
function dashboard_update_7002() {

        field_create_field( array(
            'field_name' => "dashboard_url",
            'type' => 'text',
            'cardinality' => 1,
            'entity_types' => array('manufacturer'),
            'translatable' => TRUE,
            'locked' => true,
        ));

        field_create_instance(array(
            'field_name' => "dashboard_url",
            'entity_type' => 'manufacturer',
            'bundle' => 'manufacturer',
            'label' => "Dasboard URL",
            'required' => FALSE,
            'widget' => array(
                'type' => 'text_textfield',
            )
        ));

    }
}


texts: How can I add date field in workbench moderation form in Drupal 7?

texts: I have a content type. I applied workflow for this content type of using the Workbench, Workbench moderation, Workbench access module. When using I see arise a problem to add to my software that I want to add a date field at the form#workbench-moderation-moderate-form. Can someone guide me to add a date field at the form#workbench-moderation-moderate-form.


texts: View files from multiple (filtered) nodes

texts:
I have content type Band and content type Performance. Performance has a reference field to the Band. Both content types have a media field where you can attach photos and videos. What I am trying to do is have the files from a specific Band and its Performances show up in a section (view) in the Band page. And I also want to sort them based on the Date each of the files has in its field.

All my efforts so far have been in vain. Tried to make this work with a content type view and with a file view. I feel like I will have to work with reference filters but again I can't seem to figure out how these work. I have been searching for far too long.

Any tips?

Update

Here are two screenshots of two attempts that managed to manually bring the results I am looking for, but don't really feel right.

Attempt #1

Attempt #1 tries to filter the performances and bands by taking the band name into a filter (performances have the auto label feature that adds the band name in their title). However if I have a band called "lost" and another one called "lost in space" I think I can't filter them correctly.

Attempt #2

Attempt #2 uses two reference filters (this is the first time I tried to do anything with reference filters so I guess I am using them wrong in the first place). The first reference filter brings the band node and the second brings the same band's performance nodes. If I put the node id in the preview filter below I get the correct results. However in this case that view does not accept a node id as a contextual filter because it's a file view. If I try to put a contextual filter it automatically binds to the relationship underneath it and then the reference filters don't work.

It won't let me post the reference filter views, but they are pretty basic. One takes the band id as input and renders the... band id (monkey patching at its best). The other takes the band id as input and returns the band's performances ids as a reference filter list.


texts:
I'm trying to write a custom payment gateway to work with a vendor's payment processor. They have only provided me with an endpoint to capture the payment whereas Drupal Commerce 2 works in two steps - auth and then capture. I realize that is actually better, but alas it seems my hands are tied here.
In the createPaymentMethod method, I can read the whole credit card number, but by the time I get through to the createPayment method, it only has the last 4 digits expecting the payment processor to have provided a key to pair with those.
Is it possible to access the whole credit card number in the createPayment method without storing the whole thing in the database (something I absolutely won't/can't do).
Thanks!


texts:
I am getting this error.

  Call to undefined function feeds_node_prepare() in dkan_datastore_node_update() (line 307 of /dkan/dkan/profiles/dkan/modules/dkan/dkan_datastore/dkan_datastore.module).

What could be causing the error? Could it be a module interfering with function?


texts: How to autopopulate entity reference field w/ user-created entityform submission

texts:
I'm developing a website for recruitment for research associates. I am currently using Entityforms as the questionnaire.

I've created a rule to create an entity of a certain content type, which I call "associate applicant", which has a field for entity reference. I want this field to populate with the entityform that the user submitted, upon submission.

However, right now you have to go in and edit the field and manually select the specific entityform (submission) in order to populate the field. Any advice on how to approach this problem and autopopulate that entity reference field with the user's submission?

I"m a beginner in Drupal development so any help is really appreciated! :)


texts: Custom field widget that displays a button with JS action and a hidden textbox

texts:
I have no background in working with the Drupal API, so answers will have to explain it like I'm a child.

I am trying to create a custom field module. The widget should show a button with JS onClick action that opens an external form. The user selects through a series of prompts and the external form returns XML to the page that should be stored in a hidden XML field (I'm using the XML Field module). The XML is never shown to the user, but instead powers a JS script on node view.

The formatter for the field should deliver the content of the XML field as a JS variable and not display anything on the page.

I've read through the Drupal API documentation and several tutorials on building custom fields. However, these all assume a working knowledge of the Field API, which I do not possess.

Is this possible in a field module, or should I be looking at a different way of implementing this?

I'm using Drupal 7 and the external form is a client metadata requirement I have no control over.


texts: Migrating paragraph items to their host nodes from Drupal 7 to Drupal 9?

texts:
I am trying to do a Drupal 7 -> Drupal 9 migration using the UI. It was able to convert field collection types to paragraph types. I was also able to create a few custom migrations using the d7_paragraphs_item plugin provided by Paragraphs to migrate all paragraph items from D7 into the database.
Now I need to attach them to the nodes.
My migration yaml:
id: field_content
migration_tags: {}
migration_dependencies: {}
migration_group: yale
label: Field Content Paragraphs
source:
  plugin: node_items
  key: migrate
destination:
  plugin: 'entity:node'
process:
  nid:
    - plugin: migration_lookup
      migration: d7_node_complete:page
      source: entity_id
      no_stub: true
    - plugin: extract
      index:
        - 0
  title: title
  items:
    plugin: migration_lookup
    migration:
      - accordion_items_paragraph
      - editor_items
      - highlight_files
    source: field_content_value
  field_content:
    plugin: sub_process
    source:
      - '@items'
    process:
      target_id: '0'
      target_revision_id: '1'

Except this is only doing maybe 20% of the total. It would appear that its not pulling back all possible paragraph items to stick into the field, or maybe I am just thinking of it wrong.
The source plugin is returning a set of data from Drupal 7 for a field that held Paragraph references:
class NodeItems extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('field_data_field_content', 'fc');
    $query->join('node', 'n', 'n.nid = fc.entity_id');
    $query->join('paragraphs_item', 'pi', 'pi.item_id = fc.field_content_value');
    $query->fields('fc', [
        'entity_id',
        'bundle',
        'delta',
        'field_content_value'
      ]);
    $query->fields('n', [
      'title',
    ]);
    $query->condition('n.status', 1);
    $query->condition('fc.bundle', 'accordions', '!=');
    $query->orderBy('fc.entity_id');
    $query->orderBy('fc.delta');
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      'title' => $this->t('title'),
      'entity_id' => $this->t('entity_id'),
      'bundle' => $this->t('bundle'),
      'delta' => $this->t('delta'),
      'field_content_value' => $this->t('field_content_value'),
    ];
  }

"field_content" in D9 is a Paragraphs field. It does seem to plug some values, I do see items on various nodes. But its failing because I think the lookup doesn't always return a value or maybe it doesn't know what to do with them? Also the nid: mapping needs to support multiple node types, I passed one migration. There are 12. Can I add all of them there or ?
Is this the way to attach them to host nodes? Is there a better way?


texts: How to add dynamic created css using drupal_add_css

texts:
I am trying to add a file which is located in sites/default/files/color/theme-768/color.css using drupal_add_css().

I have tried drupal_add_css($filepath), but it doesn't work. I tried putting it in template.php and hook_init(), but still it isn't included in the style tags of head section or anywhere.

How I do include a CSS file like this using drupal_add_css()?


texts: Administer simplenews subscriptions with views

texts:
In simplenews the default path to manage the subscriptions to newsletters is: admin/people/simplenews. The problem with that page is that it doesn't, for example, have any columns that would allow you to see when the subscription was added or even select all the subscriptions and perform actions on them (a feature that is available by default in vbo).

My question is the following:

Is there any way to make the specific page available for further configuration through Views so that I can add extra fields/features to it? What I'm looking for is basically something like Administration Views but for the simplenews interface.


texts: How do I remove extra space in table field?

texts:
I'm using Views Module. I created a new ContentType with 3 custom fields: (text)Criteria, (decimal)Monthly, (decimal)Semester.

I created a table style view that retrieved the ContentType I created and dropped the values into a table. I'm actually using Javascript to grab the contents of each row generating a JSON array of objects with key-value-pairs for the content of the table, then I'm doing some fancy Javascript rendering. It's just a quick way to leverage Drupal's views and get the data where I want it exactly.

Anyway, when I grab the content of the Title row, $(this).find('td.views-field-title a').text();, it works fine, but when I try the exact same thing with the other 3 rows, I end up with a lot of space and \n. So my object ends up looking like:

[
 {'title':'Correct Title','criteria':'\n     Criteria Title    ','monthly':'\n     $70.00     '},
 {...},
 {...}
]

I can't figure out where the \n and extra space is coming from. It seems to be how the view formats the fields. How can I get rid of those?

Note: I do have the fields set to Plain Text in the configuration.


texts: Create a page filter with the last article of each category

texts:
My articles are grouped in 6 categories (created by taxonomy)

I need to output a view page that contains 6 sections each one displays in a block or div the latest article of the category it belongs.

I have a solution how to do that by creating 6 views for each category filtered desc and displaying the last article and a 7th view to hold all the 6 view blocks. The only thing I don't like it about this is if the editor enters a new category I need to manually update the view.

Is there a way to display the 6 cell grid with the categories as I mentioned before?


texts:
Possible Duplicate:
  hook_schema is not creating database table

I am developing a module in Drupal 7. It is called scorm. I created scorm.install file, where I wanted to create the necessary tables, when the module is being installed. For testing I used book module: I installed it and 'book' table was created.

So I took the code from book.install, renamed all the functions prefixes from 'book_' to 'scorm_' and tried to install my module. I added this code to scorm_schema function:

function scorm_schema() {
    print 123;exit;

And 123 was printed when installing. So I removed this test code, being sure, that the hook is called.

But the book table was not created! How can I debug and find out the cause of problem?