texts: #attached css in render array not working

texts:
I am trying to render a block with a custom css with it. I have obtained a render array for the block and now I add to it:

$render_array['#attached']['css'] = array(
   base_path() . 'path/to/module/css/abcd.css',
);

return drupal_render($render_array);

The path to the css file is correct, I am able to access it in the browser. However, the css styles are not applied to the block. What are the proper steps to take now to debug this problem?

Thanks in advance!

Edit:
I have tried out Option 1, this is the result of dpm($block) in in the hook_block_view.

subject (String, 15 characters ) Correct subject
content (Array, 2 elements)

  #markup (String, 45 characters ) <span class="testtest"> Red text </span>
  #attached (Array, 1 element)
    css (Array, 1 element)
        0 (String, 58 characters ) /path/to/css

And the contents in the css file:

.testtest {
  color: #C43C55;
}

Could it be a site configuration? Thanks!


texts: How to remove the caption in gallery caption module?

texts: I'm using Gallery formatter, how to remove the caption? But I want to leave the title and alt parameters.


texts: Route callback for RegisterForm results in Call to a member function getEntityTypeId() on null

texts:
My objective: Let say there is a role named "author". I would like to have a registration form having this path: /register/author, when the user submit, he/she will get the author role (same for any other roles like /register/another_role)

Here is what I have done:

1-Creating a route: last argument will be the role name

mymodule.register:
  path: '/register/{role}'
  defaults:
    _form: 'Drupal\mymodule\Form\RegisterByRole'
    _title: 'Register by role'
  requirements:
    _permission: 'access content'

2-Extending the RegisterForm Class

class RegisterByRole extends RegisterForm
{
    public function form(array $form, FormStateInterface $form_state, $role = null)
    {
        $form = parent::form($form, $form_state);
        if (role_is_allowed($role)) {
            $form['test'] = [
                '#markup' => '<p>Test:' . $role
            ];
        }
        return $form;
    }
}

Of course I must change the submit function to assign the role, but I already have the following error when visiting the /register/author path:

Error: Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 111 of core/lib/Drupal/Core/Entity/EntityForm.php).

I found that if I add the __construct and the create functions in the RegisterByRole class definition, the getBaseFormId error disappears... But I don't understand why?... And more annoying, I couldn't get the value of my $role argument (last arg of the route).

What is wrong in my plan?


texts: How can I embed a webform in an Ionic React app?

texts:
Webform has a Share submodule that can be used in decoupled situations.
There is a video tutorial here.
However, I'm having trouble getting my webform embedded in my Ionic React app.
What I have done

Went to /admin/structure/webform/config and selected Enable form sharing under Form share settings.
Went to /admin/structure/webform, clicked the more info triangle, selected Share.

I now have the option to choose from JavaScript, Resizing iframe, and Fixed iframe, but all of these use document.write, which won't work with Ionic because the document has already been written.


texts: Views: Access CCK image delta for each image link

texts:
I have a view that for each row, outputs the first 3 images of a CCK image field.

I would like to be able to Output a different link for each image in the format node/[nid]?image=[delta]

I don't mind writing a token for this purpose, although I'm not sure how I'd access the delta number in the first place, other that some convoluted loop that just increments and resets a static variable, and even then, would that even work or is there some sort of token caching that would break even that approach?


texts:
I've created a view called "Upcoming Events" that presents upcoming events in chronological order at the url /upcoming-events/all. Each event has associated tags. Currently my contextual filter is set so that replacing all in the url with a valid tag will present just events with that tag. Tags are set up as links with the url /upcoming-events/[field_tags].

My question is two-fold. How do I set up the contextual filter so that adding more tags on the end of the url (/upcoming-events/happy-hours/drupal/ for example) will further narrow the results presented to the user? Also, how do I set up the tag links to append the field tag to the end of the url rather than replace it?


texts:
I have a design question:

I have several models that lend themselves to inheritance very well.

I have an animal object that has attributes that are shared between the dog, cat, and hamster objects very nicely.  However, the source of the dog, cat, and hamster are all from different APIs.

So what I started doing was to build my module around each of the APIs, with the necessary 'fields' effectively hardcoded in the module animal.  I knew that this horrifically violates the DRY principle; but am from the D6 (barely D7 era and hadn't really been introduced to entity types).  This was using custom tables, and custom 'models'.  This also means that I have to create the views, and all the other stuff associated with it myself.

So then I realized that I could actually use entity types for this.  The core animal module exposes only what it needs to (a small set of fields).  And the dog, cat, and hamster modules all extend the animal entity type thus giving me access to all the shared data without having to repeat myself and the added bonus of having views, handlers and the other stuff for almost free (a bit of boilerplate that is copy and paste...).

My questions are thus:

Is this thinking right, that content entity types are the way to go?
I know what I gain, but what do I lose by doing this?
Is this a good approach, i.e. is it fair to extend a base entity type?
Is it better to create bundles for each of the dog, cat, hamster or just use the extending of the animal content type?
When do you use a bundle vs extending a content type?


texts: Upload Image browser widget for drupal 6

texts: I need the following combined options, to browse and choose images from previous uploads (or) upload new image from hard drive. Currently I configured with default upload widget(file->Image), so I can choose image from hard drive only, but I don't want to upload the same(duplicate) image again and also it will save lot of space. I want to avoid same image upload, Is any module available with both options ?


texts:
I am getting the following error while updating the UUID with sudo drush config-set "system.site" uuid "d523bcdf-9d4b-45f4-9acc-a97ba4889b66" on Drupal 8.2.x.

  PHP Fatal error: Class Symfony\Component\Console\Style\SymfonyStyle contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Console\Output\OutputInterface::isQuiet, Symfony\Component\Console\Output\OutputInterface::isVerbose, Symfony\Component\Console\Output\OutputInterface::isVeryVerbose, ...) in /var/www/html/drupal/vendor/symfony/console/Style/SymfonyStyle.php on line 33
  Drush command terminated abnormally due to an unrecoverable error.
  Error: Class Symfony\Component\Console\Style\SymfonyStyle contains 4 abstract methods and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Console\Output\OutputInterface::isQuiet, Symfony\Component\Console\Output\OutputInterface::isVerbose, Symfony\Component\Console\Output\OutputInterface::isVeryVerbose, ...) in /var/www/html/drupal/vendor/symfony/console/Style/SymfonyStyle.php, line 33

How do I fix this error?


texts: FAPI text_format field value not being passed to submit handler

texts:
I created a form that I wanted to be reusable. So I created to form below to imported into a add form and a edit form. Please be aware I do have the validateForm, and submitForm function in my code.

class PaneConfigurationForm extends ConfigFormBase {

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

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state, $element = null) {

       $form['description'] = array(
          '#type' => 'text_format',
          '#title' => 'description',
          '#default_value' => '
The quick brown fox jumped over the lazy dog.
',
          '#value' => '
The quick brown fox jumped over the lazy dog.
',
          '#format' => 'full_html',
       );

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

So in my AddPane form I use the \Drupal::formBuilder()->getForm() function to get the form and apply it to my parent form. For some reason when I submit the form the value is not passed to the submit handler, only to form format.

class AddPaneForm extends Formbase {

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

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state, $element = null) {

          $form = \Drupal::formBuilder()->getForm('Drupal\_module_\Form\PaneConfigurationForm');

          $form['actions']['submit'] = array(
            '#type' => 'submit',
            '#value' => $this->t('Save'),
          );
    }

    public function submitForm(array &$form, FormStateInterface $form_state)
    {
          $form_state->getValue('description')
    }
}

What can I do to allow the format and value to be passed to the submit handler, not just the text_format field's format.


texts:
I am building a series of very similar sites, and so opted to run them all from a singe installation of Drupal 7. I have this all set up and working correctly.

As mentioned, these sites will be almost identical, but branded differently - the only changes being different logos, colours etc. Structurally, they will all be a match.

I am using Zen and building child themes for each of these sites, but I would really like to be able to make a 'master' Zen child theme which contains the bulk of the customisations, then each site could have a child of that with the few applicable brand changes required.

1) I could change the name of the parent Zen theme and customise away (and am actually tempted to do that). Its not good form though.

2) I could make one of these sites the 'master' and symlink the important bits to the other sites.

3) I could stop trying to find a solution, and just get on with the job, copy/paste in hand.

Does anyone know if there is a 'proper' way to do something like this? I'm totally flexible on any of the details - don't have to use Zen, for example.

Thanks!


texts:
I am using Commerce Invoice and Entity Print to generate .pdf-files of invoices. In Entity Print settings, I set the paper size to A4 and selected TCPDF as printing engine.
Then, I customized commerce-invoice.html.twig to my needs, which works fine.
But I cannot get rid of the two black borders that seperate the document header and footer I think.

Would be nice if anyone could give me a hint where these come from. I alread also tried to override entity-print.html.twig and remove the styles from there. Also I unchecked the checkbox in the entity-print settings.
But these borders still appear on every .pdf-generation.
Thank you very much in advance!


texts: How to rebuild a tableselect after submit?

texts:
i've a tableselect showing list of books orders with dates (of the order) i've just added two date fields to "sort" books by 2 dates. So the user should select date 1, date 2 and submit, that makes appear only books sold in this date interval. The think is; i can dsm the array of books between two dates (the query works) but the "rebuild" part doesn't work.

Here is my code :

function filtrer_commande_par_date_submit($form, &$form_state){

//getting the values from two simple date pickers
$date_1 = $form_state['values']['date_order1'];
$date_2 = $form_state['values']['date_order2'];

$result = db_query("SELECT b.uid, b.entity_id, b.date_sold,     c.username_client, edit.field_edit_target_id,ed.username_auto, title.field_title_value, pr.field_price_value FROM {bibliotheque} as b
            left join {clients} as c on c.uid = b.uid
            left join {field_data_field_edit} as edit on edit.entity_id = b.entity_id
            left join {editeur} as ed on ed.uid = edit.field_edit_target_id
            left join {field_data_field_title} as title on title.entity_id = b.entity_id
            left join {field_data_field_price} as pr on pr.entity_id = b.entity_id
            WHERE STR_TO_DATE(b.date_sold, '%d/%m/%Y') between
           '$date_1' and
           '$date_2'
        ")->fetchAll();

  // dsm($resultat); <==== this shows right result.

  $rows_date = array();

        foreach ( $resultat as $new_res ){

            $rows_date [] = array(
                'client'=> $new_res->username_client,
                'livres'=> $new_res->field_titre_latin_value,
                'id_livre' => $new_res->entity_id,
                'editeur'=> $new_res->username_auto,
                'date'=> $new_res->date_achat,
                'prix'=> $new_res->field_prix_value,
                'devise' => $new_res->devise_ed
            );
        }

        // $form_state['liste_tableau']['#options'] = array(
        //  '#options' => $rows_date             <=== doesn't work
        // );
        // $form_state['values']['liste_tableau'] = $rows_date; <=== doesn't work too
        $form_state['rebuild'] = TRUE;
    }

I want to make #options of tableselect (liste_tableau) take the new row ($rows_date) with the sorted valus by date_1 & date_2 but the tableselect doesn't change.

Please any help ?


texts: Do multiple normalizing modules conflict with each other?

texts:
Drupal Core serialization service is selecting normalizers from container by looking at "normalizer" tags and their priorities. But we have multiple modules using serialization, providing their own normalizers for the same entity types/fields, for example: jsonapi and hal. Knowing how Drupal is selecting normalizers, it looks like it has to always select the higher priority one, and multiple modules using serialization, and providing their own normalizers to the same entities, are inherently conflicting with each other.

Am I missing something?


texts: Master Detail webform or connecting/linking two webforms

texts:
I just got a project request that went from simple to complex.

the original project was just to collect basic user info, the complexity comes in, now they want the user to provide detail on his/her car or cars.  So one submission could have 1 2, 5 detail entries.

is it possible to do a master/detail setup using drupal webforms?  i need to create a webform that will have a general info in the top, ex: fname, lastname, age, location, range

there will also be a detail section of their webform that will contain: car type, partID, quantity, type, past requests for example.

Is there away to connect two webforms as there could be several details related to one submission?

Example:
Were I doing this in straight php, i would have a master/detail tables
one take holding the fname, lfname, age, location range date
one table holding car type, partID, quantity, type, past requests
the later table would have a key to connect the items to the first table, easy

How can I accomplish this, or can I accomplish this using webform?

I did a search on connect, link, combine webforms, but not getting anything concrete back, so want to see if i need to rethink the entire process before continuing down the rabbit hole.

Any ideas, advice suggestions would be greatly appreciated.

Thank you in advance.


texts: Views show content where field used in user and node entity matches

texts:
I have an entity reference field called 'field_client' (client) used on both the user entity and on a node content type called 'ticket'.

I'd like to build a view that only shows nodes where this entity reference field value matches the logged in user's client entity reference field value.

I'm struggling to determine how to build the contextual filter and if a relationship is required.


texts: What is public static function create() in plugins for?

texts:
Sometimes I encounter a function public static function create with arguments in plugin classes.

For example, here https://www.sitepoint.com/tutorial-on-using-drupal-8-plugin-derivatives-effectively/
we can see it.

public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static(
      $container->get('entity.manager')->getStorage('node')
    );
  }

Could you clarify me, what is the function for? What should it do and where is it used?


texts: Is it possible to cancel the creation of user without triggering an error?

texts:
I have a problem with account creation spam, in which a bot or other bad actor tries to create accounts using somebody elses email address. The owner of the email address flags the verification email as spam, and I get tagged by my email provider for sending spam.

I'd like to try a "shadow ban" sort of situation, in which it appears the account creation is successful, but the verification email is not sent and the account is not created.

According to Cancel user creation from hook_user_presave hook_user_presave() won't work.

I thought about using hook_mail_alter() to cancel the verification emails, and then hook_user_insert() to immediately delete the user (or maybe save the user ids, for a cron job to delete later). This seems like it could work, but I'm learning Drupal as I go, so I'm hoping somebody with more experience will be able to think of something simpler.


texts: What function does Drupal provide to save an array in a file?

texts:
I am writing a module that handles a large associative array which has string keys and floats values.

$array = array('hello' => 122.23, 'name' => 334.3, /* etc... */);

I was thinking of storing it in the database by serializing it, but the array size is dynamic, so I thought of storing it in a file to reduce access time.

What functions should I use to create the file, write the content, and read the array from the file?


texts: Receive link from row in views-template file

texts: I changed a views-template and wanted to link all elements together. Is there a different way as getting the link via regular expressions?


texts: Drupal 7 Field API min_resolution setting not applied

texts:
In my MODULENAME.install file I create some custom content types. I add some fields to these content types with the Field API. The fields are added correctly and I can use the content types as I expect. The only problem I'm facing is that I cannot get an image field to validate the minimum resolution. I can set this through the admin UI, but I am not able to achieve this through code.

The following code constructs the field:

$field = array(
'field_name' => 'featured_image',
    'type' => 'image',
'settings' => array(
    'min_resolution' => '920x370'
)
);

field_create_field($field);

$field_instance = array(
'field_name' => 'featured_image',
'entity_type' => 'node',
'bundle' => $type->type,
'label' => t('Afbeelding'),
'widget' => array(
    'type' => 'image_image'
),
'instance_settings' => array(
    'min_resolution' => '920x370'
)
);

field_create_instance($field_instance);

Like I said before, the image field is created, but the minimum resolution is being ignored. Going through the Drupal documentation isn't helping me much.

Any help is greatly appreciated.

UPDATE:

I found the solution by doing a search on the Drupal source:

$field_instance = array(
'field_name' => 'featured_image',
'entity_type' => 'node',
'bundle' => $type->type,
'label' => t('Afbeelding'),
'required' => TRUE,
'settings' => array(
    'min_resolution' => '920x370'
),
'widget' => array(
    'type' => 'image_image',
)
);

(Couldn't answer my own question yet, hence the update)


texts: How to collect time periods, calculate the total, and present in ISO 8601 format?

texts:
I am trying to get few inputs of time periods from users (it can be by choosing in dropdown).
let's say a user will be able to input in one field: "1 hour and 5 minutes" or 01:05;
In second field the user will be able to input: "2 hours and 25 minutes" or 02:25;

Then, I want to calculate and add up the  two time peirods for: "3 hours and 30 minutes" or 03:30;

It's important that all the date and time fields will be saved in ISO 8601 format, for google.

Someone can help, How can I do that?

Thanks!


texts:
I forgot to turn off the comments while creating a content type. Now when i set the Comments to Closed, the form for adding a comment is still being displayed in full node view.

Any suggestions?

Thanks!


texts: How to store Ajax Return value into variable after clicking the Submit button

texts:
I have created form with fields of State and City. After selecting the state appropriate city records will be loaded into city field till now working fine but after clicking the submit button I am not able to store city value into variable called $data1. Please guide me how to get it city value

function form_test_form($form,&$form_submit)
{
$form['state1']= array(
  '#type' => 'select',
  '#title' => t('State'),
  '#options' =>$options_state,
  '#required' => TRUE,
  '#ajax' => array(
    'callback' => '_ajaxfunction',
    'wrapper' => 'divaroundseconddropdown'
  ),
);

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

}

Ajax Function

 function _ajaxfunction($form, $form_state)

    {

$key = !empty($form_state['values']['state1']) ? $form_state['values']['state1'] : 1;

  $query_city=db_select('city', 'c');
  $query_city->fields('c',array('District_Code','District_Name','State_Code'));
  $query_city->condition('State_Code', $key, '=');

  $query_city->orderBy('District_Name','ASC');
  $city_results = $query_city->execute();
  $options_city = array();

  foreach ($city_results as $city_record)
{
    // This is correct.
    $options_city[$city_record->District_Code]=t($city_record->District_Name);
}

    $form['city_element_wrapper']['city']= array(
        '#type' => 'select',
        '#title' => t('District'),
        '#options' => $options_city,
        '#required' => TRUE,);

    return $form['city_element_wrapper'];
    }

Now I am trying to store the value of what I have selected in City into $data1 variable but I am not able to store it, Please guide me how to store

function form_test_custom_form_submit($form, $form_state){
    $data1 = $form_state['values']['city_element_wrapper']['city'];
}


texts: Checkbox list for content type in drupal 7

texts:
How do you add Content type checkbox list in Drupal 7?

I have content type "Exporter". When I edit an exporter I would like to have a list of regions that exporter is part of. In Drupal 7 how do I add a radio button field that list all regions in the exporter content type.

In Drupal 6 I had to use CCK, but I thought this was supported natively in Drupal 7?


texts:
Is there a standard way or a module that can log all node/settings modifications/updates?

I don't feel watchdog would be the best place, as it is an error log and not an update log, but I suppose it would do.

In Magento CMS, it might look something like this: http://amasty.com/admin-actions-log.html

We have had instances where something was changed and we didn't know who made the change or when the change was made.  Having a change log would have been very helpful.


texts: How to limit a user to specific OG groups based on user role?

texts:
In a quite complex project page, I have several user roles (from Drupal core). Further, the page has an internal area which is built upon Organic Groups (OG). There are a lot of groups available, each group is part of a so-called "area". These areas correspond to user roles and what I want to achieve is that users of a role may only subscribe to groups of the area with the same name.

To visualize the concept, let's say I have three user roles (besides anonymous, authenticated and administrator): A, B and C.

There is a node type called "Group" which has a select field for area, the available options are A, B and C.

There are nine groups, called A1, A2, A3, B1, B2, B3, C1, C2 and C3. I don't want users to apply for a group but immediately join (subscribe) to it, but only if the group's area matches the user's role. So user Alex of role A may only see and join A1 through A3 but not any other group.

The OG group permissions only distinguishes between non-member, member and manager. There's the option to subscribe to a group without approval, which I want. But how to combine that with the Drupal user role?


texts: How to modify the view of a new OA content type?

texts:
I followed this webinar: https://www.youtube.com/watch?v=IfStOxR9p0s

In it, Mike Potter walks you through how to create a new content type in OA and then create list view for that content type. Then he creates a new section type for that content type, where he adds the newly-created list view.

Mike did a great job and I was able to follow along fine.

At about 30:20 in that webinar, he shows that the view for the newly-created content type is just unformatted data from the content fields being spit out on to the page.

He mentions that you can do some "theming" of the page to make it look better, but doesn't cover how to do that.

Can anyone offer some guidance on that? How can I go about customizing the layout for viewing a single piece of content?


texts: Is there a way to manually run cron with Drush?

texts:
I want to be able to accomplish this:
http://mywebsite.com/admin/reports/status/run-cron

But it should be done through the Drush interface.

Can any one help me out ?


texts:
We can theme the search-result pages within search-results.tpl.php and search-result.tpl.php. But as far at it is possible to create multiple search pages(e.g. in apache solr module), is it possible to theme each page individually?

Example:

search-results--page1.tpl.php
search-results--page2.tpl.php


texts: How can I change a file field description?

texts:
How can I change the file field description without altering a module file?
The function I would like to modify is theme_file_upload_help().


texts: Group search result of drupal 7 and show them in tabs

texts:
I am using function like this. I have grouped the search output and displaying, but i need to make these grouping in tabs using any tabs feature available, how do i do it over here by using any other module function.

function arras_preprocess_search_results(&$variables) {
    $variables['search_results'] = '';
    // get a list of node types
    $nodeTypes = node_type_get_types();
    // loop through results, group by type
    $resultTypes = array();
    foreach ($variables['results'] as $result) {
        $resultTypes[$result['node']->type][] = $result;
    }

    // create fieldsets for each type
    foreach ($resultTypes as $resultType => $resultTypeResults) {
        $value = "";
        // loop through entries
        foreach ($resultTypeResults as $result) {
            $value .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
        }
        //$variables['search_results'] .= $value;
        // add fieldset

    /*    $variables['search_results'] .= theme('fieldset',
            array(
                'element' => array(
                    '#title' => $nodeTypes[$resultType]->name,
                    '#collapsible' => TRUE,
                    '#collapsed' => TRUE,
                    '#value' => $value
                )
            )
        );
      */

/* Problem here */

     $variables['search_results'] .=   quicktabs_build_quicktabs('test',array(),array('title' => $nodeTypes[$resultType]->name, 'contents' => 'test'));
    }
}


texts: I have two allowed payment methods, Paypal and Credit card. When a user checks out Pay Pal is selected by default and is shown on top. How do I change the order of these with the credit card option on div on top and make the radio button for credit card, the option selected by default?


texts: Change the front page basing on the domain

texts:
I need to write a custom module to map some static pages used as front page to some specific domains. For example,

If domain is www.abc.com, the front page should be static_page_1
If the domain is www.bcd.com, the front page should be static_page_2

I have made a form for administrator users to enter the domain name and the static page they want as front page, but now I don't have any idea on where and how to write the code for detecting the domain name and set the front page.
Any information and suggestion will be very appreciated.


texts: Using version control/deployments with Context

texts:
I've started to use Context. It actually works pretty well. I've created a context locally. It looks like, in order to get that context remotely, I have to export it and then copy and paste that into the remote server.

It's not a major pain, but we have dev, stage and live servers, plus the context isn't under version control, so any changes (or in fact the context itself) aren't stored in code.

Ideally, I'd have a situation like Views where I export the View, paste it into a file, deploy that file from version control to remote servers and the View updates on those servers.

Is this possible for context? Maybe using CTools?

The slight quirk is: I don't really like Features, and, at the moment, it seems overkill to add that as a module just for the sake of one context.


texts: Why does this field_update_instance() call not preserve all settings?

texts:
I'm working with Commerce + Addressfield (and Commerce Addressbook). In a hook_update_N I want to configure sensible defaults for the site, but one of them (default_country) refuses to stick. Why is that?

/**
 * Set some defaults to commerce_customer_address field.
 */
function example_update_7117(&$sandbox) {
  if ($field_instance = field_info_instance('commerce_customer_profile', 'commerce_customer_address', 'billing')) {
    $field_instance['widget']['settings']['available_countries'] = array('NZ');
    $field_instance['widget']['settings']['format_handlers']['address-hide-country'] = 'address-hide-country';
    $field_instance['widget']['settings']['format_handlers']['address-hide-postal-code'] = 0;
    $field_instance['widget']['settings']['format_handlers']['address-hide-street'] = 0;
    $field_instance['widget']['settings']['format_handlers']['address-optional'] = 0;
    // The above settings are preserved on save, but this one isn't.
    $field_instance['widget']['settings']['default_country'] = 'NZ';
    field_update_instance($field_instance);
  }
}


texts: How to copy view modes between content types in Drupal 8?

texts:
I've been doing my first Drupal 8 project, and a major pain point, when you have a site with 10 or more content types, is to copy a view mode to all the other content types after you set it up on one type, such as "article".

The question is, how do speed-up the process within Drupal 8 of copying a change to a view mode on multiple content types?  It can be a real pain point for developers on larger sites.


texts:
Is there a stable module for content locking (anti-concurrent editing). I found this https://drupal.org/project/content_lock but it's unsupported.
Thanks


texts:
I am new to drupal and I was adding a button for editing the data from database.
but when I am adding edit button using add content type then this error message is showing to me.Please help me to guide how to add buttons and relate them to database.


texts: What are the reasons that the "Show block on specific pages" settings wouldn't work?

texts:
I have a site with a large number of blocks, but I just added a new one that's only supposed to show on one page but it shows on every page. If I exchange it with another block I have the same problem. If I remove a bunch of blocks the problem remains.

If I put  in show on all pages except those listed, it will still show on the front page. If I only put something like about with "Only the listed pages" selected, it will still show on the front page. This is happening with different types of blocks.

I've disabled Context, and Display Suite. I've flushed the cache tons of times. What could be overriding this setting?


texts: How to use pjax module for batrik theme content?

texts: I am trying to use pjax module for content part reloading without refreshing a page but i following the instruction form pjax read me part but not worked. How to configure the module for batrik theme content part. please help me.


texts: Can theme() call a theme function from another module?

texts:
In a module I created, can I add a call to theme() similar to theme('example_def', $var) where example_def is a theme function defined from another module?

function def_theme() {
return array(
  'example_def' => array(
    'arguments' => array('nid' => NULL)
  ));
}

function theme_example_def() {}


texts: Why is css not working as expected with Omega

texts:
Making site with left side menu items built on Omega responsive grid. Setting up the global.css to theme out some page elements, like this menu.

Problem: Used css not used in the browser. Instead system.menus.css is used.
Question: Why.

CSS: for menu

/*============== Menu Items ====================*/
.menu ul
{
    padding:8px;
    margin:0px;
    font-family:Arial, Helvetica, sans-serif;
    font-size:1em;
    color:#FFF;
    list-style:none;
    text-indent:15px;
    background:#0000a2;
}
.menu ul li
{
    background:#0000a2;
    line-height:28px;
    border-bottom:1px solid #000;
}
.menu ul li a
{
    text-decoration:none;
    color:#FFF;
    display:block;
}
.menu ul li a:hover
{
    background:#3ea5ea;
}
.menu ul li#active
{
    background:#3ea5ea;
}

====================================

Chrome inspector data:
media="all"
ul.menu {
border: none;
list-style: none;
text-align: left;
}
dea.harland.tkmedia="all"
.menu {
margin: 0;
padding: 0;
}
dea.harland.tkmedia="all"
p, dl, hr, h1, h2, h3, h4, h5, h6, ol, ul, pre, table, address, fieldset {
margin-bottom: 20px;
}
dea.harland.tkmedia="all"
ul {
list-style: disc;
}
user agent stylesheetul, menu, dir {
display: block;
list-style-type: disc;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;
}

Inherited from body.html.front.logged-in.page-node.toolbar.toolbar-drawer.omega-mediaqueries-processed.omega-equalheights-processed.alpha-debug-processed.responsive-layout-wide

dea.harland.tkmedia="all"
body {
font: 0.75em/1.3em Verdana, Helvetica, Arial, sans-serif;
}
dea.harland.tkmedia="all"
body {
font: 13px/1.5 Verdana, Helvetica, Arial, sans-serif;
}


texts: Ubercart shipping quotes are being based on total before discounts

texts:
I'm hoping someone can help with this.
A site I built (www.bebeperla.com) is using Ubercart 7x-3.8 and Ubercart Discounts 7x-2.0 Alpha3.

The customer gets free shipping for orders over $80, but if they use a coupon to bring the total for the order below $80 they're still getting free shipping.

My shipping quotes are flat rate and the rules are based on a data comparison of the order:order-total.  Unfortunately it's not working - it seems to be calculating the shipping from either the sub-total or the total before the coupon is applied.  Any ideas?  I've searched the web but I can't find an issue that matches.


texts: Nodes do not save, but instead redirect to edit page again

texts:
When my client, using her account, attempts to save a node, she is sent back the node edit page without any error messages. The node is not saved. The problem doesn't seem to happen when she plays back the audio in the AudioRecorderField on the node before saving, but not every node needs audio. Any ideas?

Fields on node:

Entity Reference to 'subheading' node
title
taxonomy
other taxonomy
filefield with audio recorder widget from AudioRecorderField
plain old filefield


texts: Bootstrap 3, how disable auto-added Glyphicon?

texts:
I use Bootstrap (v3) with Drupal 8. When I create a button named "Search something", bootstrap adds automatically a "Search" Glyphicon. I do some web searches, but I don't find how "disable" (or hide?) the 'search'auto-added glyphicon of my button.

When I create a sample submit button from a Form Class custom module :

public function buildForm(array $form, FormStateInterface $form_state) {
...
$form['submit'] = [
  '#type' => 'button',
  '#value' => 'Search something',
];

If I go to the page where there is my form, the button have automatically a magnifying glass glyphicon :

I want display my button without any glyphicon, how can I do that ? I must add a class to my button ? which ?

Thank you !


texts:
I'm using Profiler to create a Drupal 7 installation profile, which works great -- however, it doesn't set Seven as an admin theme, and thus falls back on Bartik (The default theme).

Is there any way to set the default admin theme within Profiler?


texts: Use different comment template for replies-to-top-comment

texts:
I tried to make StackExchange-like comment section with different template for the comment replies. I create two template for both top-level comment and its replies. This is the result of the two comment.tpl.php file rendered and then collated in GIMP.

This is comment.tpl.php used for top comment contained in cyan box.

  <div<?php print $attributes; ?>>

      <?
        print render($avatar) . "
";
        print $commenter_name . "
";
        print $creation_date;
      ?>

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

While this is comment.tpl.php used for comment reply contained in yellow box.

  <div<?php print $attributes; ?>>
  <?php
    print render($content['comment_body']);
    print " - " . $commenter_name;
    print render($content['links']);
   ?>

If i use one of these template, it will effect ALL the comments as shown below.

I know I can change the style rudimentarily via theme css as suggested in this question, but going by this route means that I have to create one-size-fit-all template for both case that won't be pretty.

My question is: Is there any template file I missed or any other strategy that I can employ to make separate template that will target only the replies-to-top-comment?


texts: Force access denied on 'admin/structure/menu' for everyone except admin

texts:
I need to write a "simple" feature in custom module which returns access denied for all the users except admin who tries to rich 'admin/structure/menu'. I've tried with hook_page_alter, hook_page_build and also with hook_menu_alter, but none of those functions work. Function hook_menu_alter is caching menus so it sets flag:

$items['admin/structure/menu']['access callback'] = FALSE

to all users and I (as admin) can't see this page also. Any help?


texts: How can I insert fields from custom content to custom form?

texts:
I have a problem with form. I had to create a custom content with fields. User can put variables into those fields and save to database, for example "Anna" into column field_student_name in table node__field_student_name. I see this connection where every field from this content type is saved under particular node.
Now I need to create a form with fields, which values will go to the same database tables, for example in this form I have a form field where I put "Tom", and this value is saved in table node__field_student_name in column field_student_name (the same as Anna in custom content).
At this moment I see two main potential ways to accomplish this task:

insert form from custom content to my new form  with entity.form_builder

I added this two lines info code:
$node = \Drupal\node\Entity\Node::create(['type' => 'my_students']);
$form = \Drupal::service('entity.form_builder')->getForm($node);
return $form

And this works fine, but I need only part of those fields :( And I don't wanna see section for admin like "add new revision" etc. Moreover, "Submit" button is on the top of the page

Create a form and in submit function do something like
$node->set('title', 'titile1')

but I prefer way #1. Besides that, I don't know how to do it with way #2. I don't know how can i put variables from $form['student]' into field_student_name column in node__field_student_name table. Moreover i am not sure if it is ok and if nodes id etc will be added in correct way.
To sum up, I think way #1 is better and easier but I don't have such a big knowledge to do this  and maybe here are more advanced, helpful people who can help me.
EDIT
I've create new mode student_user in student content type:
core.entity_view_mode.node.student_user.yml
langcode: en
status: true
dependencies:
  module:
    - node
id: node.student_user
label: student
targetEntityType: node
cache: true

core.entity_view_display.node.student.student_user.yml
langcode: en
status: true
dependencies:
  config:
    - core.entity_view_mode.node.student_user
    - field.field.node.student.field_name
    - node.type.student
  module:
    - options
    - user
id: node.student.student_user
targetEntityType: node
bundle: student
mode: student_user
content:
  field_name:
    weight: 103
    label: above
    settings:
      thousand_separator: ''
      prefix_suffix: true
    third_party_settings: {  }
    type: list_default
    region: content
hidden:
  links: true

and here i tried with routing
student.student_user:
path: '/test'
defaults:
_entity_view: 'node.student_user'
_title: 'Students'
requirements:
_permission: 'access content'
_entity_access: 'node.view'
I received an error
RuntimeException: Failed to find entity of type node in route named student.student_user

And then i tried with form
i added core.entity_form_display.node.student.student_form.yml and core.entity_form_mode.node.student_form.yml
and then i tried return it in controller
<?php

namespace Drupal\student\Controller;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\node\NodeInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Routing;

class TestController extends ControllerBase {

  function test() {

    $node = \Drupal\node\Entity\Node::create(['type' => 'student']);

    $form = \Drupal::service('entity.form_builder')->getForm($node, 'student_form');

    return $form;
  }
}
?>

error
Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "node" entity type did not specify a "student_form" form class.


texts: Custom teasers and show summary checkbox

texts:
The function generating teasers in D6 does not make nice teasers.  At the same time I do not want to bother my users to set teasers themselves, I would rather get rid of the whole system.

Anyway, I tried writing a little helper module which went through the published nodes and tried to correct teasers that were too short or too long.

My problem:

Between the node_load() and a node_save(), what parts should I care about, just place a <!--break--> in $node->body or adjust $node->teaser?
I had the problem after adjusting $node->teaser and deleting the break; the "Show summary in full view" checkbox was unchecked when manually editing this node.  Which variable is controlling this checkbox and how do I set it?
If I wanted to implement some teaser-corrections via hook_nodeapi(), which event should I hook to, when I do not want to patch the node core module and interfere with its node_teaser() function?

I know there are a couple of modules around, that store teaser data in separate CCK fields.  I would like to avoid this if possible.  (and yes, I want to have a proper value for the teaser variable and not just manipulate the output via views etc.)


texts: In Drupal 7, where is the code for the "powered by Drupal" block?

texts: The "powered by Drupal" block used to be a module in Drupal 6.  I can not find this module in Drupal 7.  Where do I find this module/block? So I can duplicate it, or modify it.


texts:
How do i make a view that:

1)displays all the content tagged with a term in a list?

2)displays all the content tagged with a parent term in that list? (two levels up)

3)displays all the content tagged with a child-term in that list?  (only one level deep)

4)Page title=tag

5)url for that page : http:zee-online.be/tag-name

I tried it, but i couldn't get it to work.... Now i have a view for each term, and when i need to change something, that takes an hour to do it for all the terms.


texts:
I'm having the issue generating the indexing for comments with Search API.
While configuring, I used the datasource comments and added following fields for indexing. comment_body, cid, comment_type, created, entity_type.
and this is the error I get.
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=8926&op=do_nojs&op=do
StatusText: parsererror
ResponseText: Error: Call to a member function toArray() on null in rdf_comment_storage_load() (line 239 of /home/xxxxxxx/public_html/core/modules/rdf/rdf.module).

While further investigation, I found that the line # 239 has the following code.
$comment->rdf_data['date'] = rdf_rdfa_attributes($created_mapping, $comment->get('created')->first()->toArray());

Where, $comment->get('created')->first() returns NULL, $comment->get('created') is the object of type FieldItemList which has the empty list that we can see with $comment->get('created')->view()
I dont know if I'm doing something wrong with configuration (prety much this is the case) or there is the issue with code, as I'm new to this CMS. I realy appreciate your help in this regard.
Thanks in advance.


texts: Change Classes in Nav-Tag of Custom Menu

texts:
On a Drupal 8 installation, I have a menu in the sidebar first region. I want to add classes to bootstrap classes to the different levels of that menu. For that I created a my own menu template, which looks like this:

{#
/**
 * @file
 * Theme override to display a menu.
 */
#}

{% import _self as menus %}

{{ menus.menu_links(items, attributes, 0, my_menu) }} {# 1. #}

{% macro menu_links(items, attributes, menu_level, my_menu) %} {# 1. #}
    {% import _self as menus %}
    {# 1. #}
    {%
    set menu_classes = [
    'navbar-nav', 'mr-auto' ~ my_menu|clean_class,
    ]
    %}
    {# 1. #}
    {%
    set submenu_classes = [
    'navbar-nav', 'mr-auto' ~ my_menu|clean_class,
    ]
    %}
    {% if items %}
        {% if menu_level == 0 %}

 {# 1. #}
        {% else %}

 {# 1. #}
        {% endif %}
        {% for item in items %}
            {# 1. #}
            {%
            set item_classes = [
            'nav-item' ~ my_menu|clean_class,
            item.is_expanded ? 'expanded' ~ my_menu|clean_class,
            item.is_collapsed ? 'collapsed' ~ my_menu|clean_class,
            item.in_active_trail ? 'trail' ~ my_menu|clean_class,
            ]
            %}
            {# 1. #}
            {%
            set link_classes = [
            'nav-link' ~ my_menu|clean_class,
            ]
            %}

{# 1. #}
                {# 1. #}
                {{
                link(
                item.title,
                item.url,
                item.attributes.removeClass(item_classes).addClass(link_classes)
                )
                }}
                {% if item.below %}
                    {{ menus.menu_links(item.below, attributes, menu_level + 1, my_menu) }} {# 1. #}
                {% endif %}

        {% endfor %}
        {% if menu_level == 0 %}

        {% else %}

        {% endif %}

    {% endif %}
{% endmacro %}

This works fine. However, I also need to change the classes of the nav tag. I can't seem to figure out, how that can be done and I can't find any information anywhere explaining this. So how do I change the nav tag classes of that menu?

In the end I want it to be a bootstrap offcanvas menu like this one:
https://getbootstrap.com/docs/4.0/examples/offcanvas/

But I just can't seem to change the nav tag classes, since I don't know how.


texts:
I want to create a menu that will be shown on the node if it is part of a book. For example like this:

That menu should be shown for all books, which means I don't want to have a separate block for each book in the system.

I am not interested in how to implement accordion functionality, I just need a way to get menu items for all book elements of current node.

Book module provides a block with books navigation, but I don't want all books to be visible in this menu.


texts:
I am trying to homepage as <domain>/url_path, which Drupal allows via site configuration.

However how Drupal internally does it is by setting up url_path as homepage and a 301 redirect from url_path to /

Now what I am trying is to avoid this 301 redirect and open homepage as <domain>/url_path.

The reason it matters is because we have setup a logic to redirect request based on url_path to different cms so any request to <domain> will be served from non Drupal CMS and <domain>/url_path/* should go to Drupal and <domain>/url_path acts as kind of hompepage of subsite on Drupal but problem comes when Drupal redirects <domain/url_path> to <domain> and then request never comes back to Drupal since it get resolves via non Drupal cms via cloudflare rules.

I know the workaroound would be not to have url_path as front page but then I have to programmatically set site logo, breadcrumb Home link and <front> to act as <domain>/url_path

I am looking for a way to avoid <domian>/url_path redirect to <domain> which should in turn fix everything else.


texts:
We recently updated to Drupal Core 8.6.2 and noticed there are changes to module dependencies. We are noticing that drupal: is added before the module names. We were unable to find any documentation that further explains it.

How would we add Drupal Core modules as dependencies on custom modules post 8.6.2?

mymodule.info.yml example before 8.6.2

type: module
name: my module
description: my custom module
package: 8.x
core: 8.x
dependencies:
  - field
  - image

mymodule.info.yml example after 8.6.2

type: module
name: my module
description: my custom module
package: 8.x
core: 8.x
dependencies:
  - drupal:field
  - drupal:image


texts:
I want to print "your_variable" (array) in my twig template, but i have errors.

I have .theme in my theme  :

function MYTHEME_preprocess_views_view_fields(&$vars) {
   $tempstore = \Drupal::service('user.private_tempstore')->get('evenementrimouski');
   $some_data = $tempstore->get('nid');
   $vars['your_variable'][] = array(3,4,5,6);
}

My "views-view-field" twig :

{% for  value in your_variable %}
    {{ value }}
{% endfor %}

The code work but i have errors :

User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).

User error: "1" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).

Someone have idea to resolve this problem ?

I use Drupal 8


texts: How do I calculate field_1 + field_2 in Twig?

texts:
I have two fields. {{ content.field_1 }} is 2; {{ content.field_2 }} is 5.

How do I multiply them to obtain 10, in a template file?


texts: Views custom field select list like views custom field

texts:
I'm looking for a module which can allow to add a select list like views customfield provides a text field.
The select list are on the based of above fields.
Example :
I have Edit and delete operations in each views row corresponding to the result.I need these operations in select list.
Any module suggestions ?

P.S. : Please don't suggest about views_php.I can write custom handlers instead of this module.


texts:
In my Drupal 8 site, I am developing a custom block in my module custom, with some text and some images. I created a template, and everything works fine. Now I need to add some images for my custom block, and I don't know how to pass the base URL to call those images.

In Drupal 7 I used the following code.

function bloques_block_view($delta = '') {
    $block = array();

    $ruta = $GLOBALS['base_url'] . '/' . drupal_get_path("module", "mymodule");
    $link = $GLOBALS['base_url'] ;

  switch ($delta) {

//footer
    case 'footer':
      $block['subject'] = '';
      $block['content'] = leer_template('footer.tpl', array('%ruta%' => $ruta, '%link%' => $link));
      break;
  }
  return $block;
}

Everything works well, but in Drupal 8 it is a little different. The problem comes with build().

    public function build() {
    $ruta = 'holamundo',
    return array(
        '#theme' => 'mymodule',
        '#title' => 'my title ',
        '#ruta' => '
' . $ruta . '
'
    );

}

Just the title works in the template file; $ruta is not working.

My Custom Block {{ title }}-{{ ruta }}

I don't know if this is the correct way to declare the base URL (just like I did in Drupal 7).

  $ruta = $GLOBALS['base_url'] . '/' . drupal_get_path("module", "bloques");


texts: How to limit users to posting 1 node per a day?

texts:
I am making a diary website, where users can make a daily diary entry. A node acts as a diary page, so naturally I need to limit the user to make 1 node per a day. How can I do this?

Steps I have tried

Using Node Limit

This contains an option for 1 node per a day. But in fact, it is 1 node per 24 hours. So if my user makes a diary entry at 3:00pm, they have to wait until 3:00pm the next day until making the next one. Because it is diary, it would be better if the limit reset at Midnight every day, but there doesn't seem to be a way of doing this.

Using Rules

The problem with Rules is that you have to fire off the rule on Node Creation. This creates a usability issue, as my user will finish their (unallowed second) diary entry before being told that it is not allowed.


texts: Is the i18n submodule Taxonomy Translation necessary at all?

texts:
I am developing a multilingual site. The client enters the content, which is classified in taxonomies (vocabulary terms), which are translated for each language. My client has asked me if it was not better to assign a category in native language, and the system could translate later. I have replied that it is better to assign a different language node a translated term, using Taxonomy Translation capability, as later the search in the Views, etc., the friendly URLs, etc., are better designed. For example, if I have social-networks and redes-sociales (Spanish for social-networks) as a filter, I can better filter using a simple conceptual filter.
Do you think this is the correct approach ? The proposal of the client seemed reasonable, but there were many pitfalls and complicated code behind of it.


texts: Title's will not show translated version (multilingual site) in View list

texts:
I am working on a multilingual drupal website (webshop with commerce_kickstart-7.x-2.37, drupal 7.43).

My articles are perfectly translated, even the titles. So when I go to the page of the article and change the language it shows the translated content including title.

I then made a new view. With that view i created a page to have all the titles of the articles in a list. The thing is though that those titles will not translate when i change the site language while it does perfectly change on the article itself!

Any help? Is it because I do not have internationalization views? I don't get why it is translating on the article itself but not on the overview page.


texts: How to patch a file that is not in a module's git repo?

texts:
I want to patch CheckoutCartEventSubscriber.php, which can be found in /web/modules/contrib/commerce/modules/checkout/src/EventSubscriber when installed via composer.
So I cloned Commerce from the drupal.org git repository, navigated to the /modules/checkout/src/, and found that there is no EventSubscriber directory.  All the other directories that can be found in the composer install exist except EventSubscriber.
The github repo browser doesn't show the EventSubscriber directory, either.
So where is this directory? How can I find the file to patch it?


texts: Accessing Additional User Profile Fields

texts:
I added a dozen or so new fields (in Drupal 7) to the user profiles using:

Configuration -> People -> Account Settings -> Manage Fields
(admin/config/people/accounts/fields)

How can I access these values?  They do not seem to be part of $user

Tried, without success:

global $user;
var_dump($user);


texts: form ajax how to change multiple elements

texts:
How can i change multiple form elements in ajax callback and get this changes in future ajax callbacks?

i would like to set custom class to multiple fieldset's in ajax callback function:

   if (something){
    $form['fieldset_01']['#attributes'] = array('class' => array('custom_class'));
    $form['fieldset_02']['#attributes'] = array('class' => array('custom_class'));
    }else if (somethingelse)
    $form['fieldset_11']['#attributes'] = array('class' => array('custom_class'));
    $form['fieldset_12']['#attributes'] = array('class' => array('custom_class'));
} etc...
return $form;

When $form is returned, the element that i have set in this call in rendered fine, with new class but the element's that i have rendered in previous calls have lost this new class. Like they were rendered with default values.

Any help will be much appreciated!


texts: Superfish menu - how to remove parent sign: "PARENT_LINK >>"?

texts:
I built my main menu (horizontal) using superfish module.

All the parent links in the menu (that has drop down menu with childs) has a sign.
For example it looks like that: "PARENT_LINK >>"

I really tried to find a solution through CSS files, but couldn't solve it.

How can I remove the ">>" sign?


texts:
I created link field in cck and add the URl like with apostrophe
(https://www.sample.com/test's_data/test.pdf).

But the View output displayed as
(https://www.sample.com/test&#039s_data/test.pdf); As per the guidelines it is correct but my requirement is different. The URL points to a third party website it's rejecting with Access denied error message.

How to prevent the single quotes to be transformed to html entities?

I'd prefer if check_plain has the another argument we can pass the flag as well !.


texts: Is the Panels simple cache lifetime a minimum or maximum?

texts:
In Panels, one can configure caching for blocks/content panes/etc.  The built-in method is Simple Cache, for which two settings can be configured: Lifetime and Granularity.

For Lifetime, one can choose a value from 15 sec to 7 days.

Is this lifetime a minimum or a maximum?  In other words, if I set the Lifetime to 7 days for a content pane, will that content pane be cached for 7 days no matter what?  Or will it be cached for 7 days unless it is updated?


texts: How to theme "My Results" (quiz module) tab that´s inside the user´s profile?

texts:
I´m using quiz module in Drupal 7, and need to theme the output in "My Results" (wich is a tab in the user profile page).
Here´s the module´s function :
// THEME FUNCTIONS

/**
 * Theme the user results page.
 *
 * @param $results
 *  An array of quiz information.
 * @return
 *  Themed html.
 *
 * @ingroup themeable
 */
function theme_quiz_get_user_results($variables) {
  $results = $variables['results'];
  $rows = array();

  while (list($key, $result) = each($results)) {
    $interval = _quiz_format_duration($result['time_end'] - $result['time_start']);
    $passed = $result['score'] >= $result['pass_rate'];
    $grade = $passed ? t('Passed') : t('Failed');
    $passed_class = $passed ? 'quiz-passed' : 'quiz-failed';
    if (!is_numeric($result['score'])) {
      $score = t('In progress');
    }
    elseif (!$result['is_evaluated']) {
      $score = t('Not evaluated');
    }
    else {
      if (!empty($result['pass_rate']) && is_numeric($result['score'])) {
        $pre_score = '';
        $post_score = ' %
' . $grade . '';
      }
      else {
        $post_score = ' %';
      }
      $score = $pre_score . $result['score'] . $post_score;
    }
    $rows[] = array(
      'title'       => l($result['title'], 'node/' . $result['nid']),
      'time_start'  => format_date($result['time_start'], 'short'),
      'time_end'    => ($result['time_end'] > 0) ? format_date($result['time_end'], 'short') . '
' . t('Duration :  @value', array('@value' => $interval)) : t('In Progress'),

      'score'       => $score,
      'evaluated'   => $result['is_evaluated'] ? t('Yes') : t('No'),
      'op'          => l(t('View answers'), 'user/quiz/' . $result['result_id'] . '/userresults'),
    );

  }

  if (empty($rows)) {
    return t('No @quiz results found.', array('@quiz' => QUIZ_NAME));
  }

  $header = array(
    t('@quiz Title', array('@quiz' => QUIZ_NAME)),
    t('Started'),
    t('Finished'),
    t('Score'),
    t('Evaluated'),
    t('Operation'),
  );

  $output = theme('table', array('header' => $header, 'rows' => $rows));
  $output .= '
' . t('@quizzes that are not evaluated may have a different score and grade once evaluated.', array('@quizzes' => QUIZ_NAME)) . '
';
  return $output;
}

Now, all I need is to theme the output, and maybe add some special header before the results.
I´ve tried this at my template.tpl.php file, without any success:
function mythemename_quiz_get_user_results($variables) {
print "This is some information";
print "
";
print $variables;
print "
";
}

Now I know that print $variables; isn´t the way it should print an array, but the way to do this in Drupal 6 was this (I´ve took this code from an issue in Drupal´s forums):
function phptemplate_quiz_get_user_results($results) {
  // $results - An array of quiz results.
  // overriding statements
  print_r($results);
}

The function´s name changed, but the process shouldn´t be similar?
Thanks for your help!


texts:
I've been working with the entityQuery to query the db and get an array of filtered nids however I need to add an expression to my query.

I've checked the Query class and found a protected sqlQuery attribute that has access to addExpression(). In my case I'm not extending the class but rather instantiating it through \Drupal::entityQuery('node').

Also after checking a bit I found that the Select class has a function addExpression() that does exactly what I need, but then I lose the entityQuery and has to addJoin/addField and so on for each of the fields I would like to include in my conditions.

My objective:

$expression = "
    (
        6371000
        * acos(
            cos( radians({$latitude}) )
            * cos( radians( {$latitudeField} ) )
            * cos(
                radians( {$longitudeField} )
                - radians({$longitude})
            )
            + sin( radians({$latitude}) )
            * sin( radians( {$latitudeField} ) )
        )
    )";
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition(`field_city`,1,'=')
->addExpression($expression, 'distance');

$nids = $query->execute();

Did I miss something ? Is there any other way to achieve what I want ?

EDIT: I found this approach but doesn't seem straight forward

EDIT2: Better approach is this


texts:
I've got a shop selling downloadable product variations. I'd like to display the Commerce Files field description to anonymous users as text only.

Here's how it currently appears for registered users:

The field description visible is an active link...

--

Here's the current display for anonymous users

No description available

--

I can't find anywhere in the UI that allows for displaying the description without a link to all users. Here's the display options
.

Any ideas?


texts: D6 to D7: How can I get all the migrated content to have the "Text format" of "Full HTML" for the body

texts:
I am migrating content using both the migrate, migrate_d2d and my own custom module which references the 2 migrate modules.
The below code successfully migrates content from Drupal 6 to Drupal 7 when registering and running the migration of "PressMigration" within the .module file but I always want the Drupal 7 migrated content body area to have the "Text format" of "Full HTML".
How can I get all the migrated content to have the "Text format" of "Full HTML" for the body.

Thanks,

John

class PressMigration extends DrupalNode6Migration {

  protected function query() {
    $query = parent::query();
    //Only include specific nodes in migrationj
    $query->addJoin('LEFT OUTER', 'term_node', 'tn', 'n.vid=tn.vid');
    $query->addField('tn', 'tid', 'tn.tid');
    $query->addField('tn', 'vid', 'tn.vid');
    $query->condition('tn.tid', '115', '=');
    return $query;
  }

  public function __construct(array $arguments) {
    parent::__construct($arguments);

    $this->addFieldMapping('field_release_date', 'field_release_date');
    $this->addFieldMapping('field_contact', 'field_contact_information');

    $this->addFieldMapping('field_subtitle', 'field_sub_title');
    $this->addFieldMapping('field_teaser', 'field_media_excerpt');
    $this->addFieldMapping('field_custom_title', 'field_custom_title');

    $this->addFieldMapping('field_alt_lang', 'field_alternate_lang');
    $this->addFieldMapping('field_related_item', 'field_media_related');
    $this->addFieldMapping('field_archiving_date', 'field_archive_date');
  }

}


texts: How to add class only to top level ul in main menu

texts:
I am new to drupal theming.I want to add class only to top level ul in main menu.Using theme_menu__tree_main_menu() affect all the ul tag.I found this for adding class only to top level..https://www.drupal.org/node/988694
function THEMENAME_menu_tree__menu_top_menu($variables) {
 return '' . $variables['tree'] . '';
}
But it didn't work.Doesn't adding any class.Am I missing something?Please Suggest Me!!Thank


texts:
I have read many articles on improving the page load for Drupal and used as many steps as possible to enhance the speed of the site.

I installed the FireFox pluggin YSlow to get feedback on my site.  I scored a 91 with an A rating thanks to the changes recommended in the forum.

YSlow is giving me an Grade F on Configure entity tags (ETags) and Grade F on Use cookie-free domains.

Are ETags and Cookie-Free domains, something I should concern myself with?

Even though I have a good rating, I still feel the home page loads slowly.  Even going from a page with images to a text only page there is a delay.

Thank you.


texts:
I'm using the check_markup function when printing results from a custom textarea field. The issue I'm having is with urls/links.

If an url contains the scheme (i.e http.www.example.com) the output is just an empty  element with an empty href.

If an url does NOT contains the scheme (i.e www.example.com) the output is www.example.com. The link seems to works but the href is still empty.

I have checked the "convert url to links" option in the Text Format configuration and all other filters are applied to the text correctly.


texts: How to add css class to block using mytheme_preprocess_block() hook?

texts:
I need to add some css classes to each list item in a menu block that I created. I thought I could accomplish this by using the following code:

function mytheme_preprocess_block(&$vars) {

  if ($vars['block_html_id'] == 'block-menu-block-7') {
    $i = 1;
    foreach ($vars['elements']['#content'] as $key => &$item) {
      // get each list item and add some css
      if (strpos($key, '#') === FALSE) {
        $item['#attributes']['class'][] = 'col-' . $i++;
        if ($i > 3) {
          $i = 1;
        }
      }
    }
  }
}

However when I try this, I do not see the new class being added when I inspect the element although it does look like it is being added with this code. What am I doing wrong? I am using Drupal 7 by the way.

Thanks.


texts: Taxonomy term name as contextual filter for view

texts:
In D7 I was able to filter a view according to a taxonomy term name taken from the URL. An example would be this URL

http://www.gbyte.co/tags/drupal-planet/rss.xml

"drupal-planet" would be converted to the taxonomy term ID which then would filter the view results accordingly.

Now I have set up a corresponding D8 view with a contextual filter "Content: Tags (field_tags)", field_tags being the taxonomy field. However the D8 view will only show results when I pass the actual term ID into the URL like this:

http://www.gbyte.co/tags/9/rss.xml

I would like it to also work with the term name like D7 did. Is the functionality missing, or do I need to configure the view differently?


texts: How to change the author and date of a new comment before posting it?

texts:
I am copying the content from my old non-CMS (Weebly) website to my new Drupal website by manually filling in node forms and comment forms. I would like to recreate all the original authors and posting times on the new website. As a first step, I have created a user account for all the people who contributed to the old website.

Adding nodes works perfectly: as an administrator, I can post new nodes as another user and change the posting time before publishing.

Now, I would also like to add new comments, and change the author and date before posting. I know that one can administrate a comment after posting it, as shown in the screenshot below.

However, it is vital that the desired changes are made before posting comments, since publishing triggers multiple Rules, related to User Points, Flags etc. Otherwise, the wrong users are rewarded User Points, for example.

How can I do that?


texts: How to access image style url from jQuery code?

texts:
image_style_url() generates proper links, but sadly it's only a PHP function.

Let's assume I want to substitute file icon with preview image on hover:

(function($) {
  Drupal.behaviors.ImagePreview = {
    attach: function (context, settings) {

      $('.form-managed-file', context).on('hover', function(){
        $(this).find('img').attr('src', $(this).find('a').attr('href'));
      });

    }
  };
})(jQuery);

Not the smartest code in the world, but simple, works and illustrates my example. Now, it will show image in the resolution user uploaded. But I need a thumbnail. It's a built in style so I don't need to test if it exists, but I do need valid security token and I need to respect all the Drupal file system settings, just like image_style_url() does. How can I achieve this with jQuery?

Note: In my case both input and output need to happen on jQuery side, as the image may not even be on the server when page is rendered.


texts:
I have the following issue:
When a user register to the site he receives a message with a unique url in order to activate his account. so far so good. However when the user clicks the link provided instead of the normal page it redirects to http://example.com/user/%5Buser%3Aoriginal%3Auid%5D/view
If the user copies the link from the email in the url bar then the page loads correctly. I tried all the tokens available but the problem remains.Where should I search?


texts:
I'm using the Devel module, and the following snippet of code to insert its links into my theme.

<?php echo render($page['devel']); ?>

The result is a h2 element with the Development title in it, and then followed by the links as expected.

I want to hide the title, is it possible at all?

This is what I ended up doing.

    <?php if(array_key_exists('menu_devel', $page['devel'])):?>
        <?php foreach($page['devel']['menu_devel'] as $link):?>
            <?php if(is_array($link) && array_key_exists('#title', $link)):?>

<a href="<?php echo $link['#href'];?>"><?php echo $link['#title'];?>

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

Does this seem acceptable, or is there a preferred way to do this in Drupal?


texts: What can break quickedit, and how do I fix it?

texts:
We hired someone else to make our theme, and they gave us something with the quickedit not working.  What can cause this to break, and how do I fix it?

Here's what my contextual-links ul looks like right now:

Quick edit

The entitynodeedit-form li is empty, as well as the delete li.  What is supposed to fill them in, and how do I fix it?


texts:
I have created a omega sub theme. In header first region I have put a views slideshow banner which was working fine but all of a sudden it disappears from anonymous user. I tried to put some other blocks in that region but not thing is showing up for anonymous user, but when I am logged in it shows banner and the blocks in that region.

Any idea ???


texts: Drupal doesn't send email to reset password

texts:
While having difficulty logging, I reset my password but the page stays and does no form action.

After I changed my password in the mysql database, I went to log in and the page does nothing even when I hit submit. Is there something wrong with my installation?


texts:
I am using Drupal 8 and I cannot find where the multiple selection checkbox for my taxomomy field is.

And the result is radio buttons.


texts: What aggregator element represents the image in a feed?

texts:
I have an RSS feed from a partner that I link to from my menu.

If I link directly to the XML page -- http://www.criticalblast.com/sync-collaboration.xml -- then it will display the full feed with the attendant thumbnail image and links.  However, doing this takes the user outside the structure of the website, and they have to hit BACK to return to it. (This link does not work for all browsers, either -- some of them will dump the XML, some, like IE 11, Firefox, will actually format and display it.)

I have created a Page to display selected elements of the Aggregator feed -- http://www.criticalblast.com/sync-aggregator -- while staying within the structure of the site. I'm 99% happy with that, but I'd love to get the thumbnail images included. Of the list of aggregator items that I can include when modifying my view, I don't see anything jumping out at me that seems to be the thumbnail image. Anyone have any success with this in the past?

SUMMARY: I can see thumbnail image in feed, I cannot see it in Page display format.

Thanks!


texts: Find if the drupal node is published or not published in node_save()

texts:
I am trying to find if the user has set the node to be published when creating a node. Upon hitting save, the call to node_save() is done; I tried to call print_r($node), but nothing seems to show up in the data which relates to the publishing status of the node.

How would I find out if the node is set to be published? Is there a way I can find out if an alias is set?


texts: Taxonomy and Views - Creating a view based off of user selection

texts:
Been working with Drupal for a few weeks, and I have a question:

I have a large amount of content for content type X. I have built a view that returns certain fields from X nodes. Is there a way to build a user interface that will allow users to see all taxonomy tags for X and select a tag and then use that tag as a filter for the view?

For example, a user wants to see all results that are tagged "SEO." They will then see the views results for all nodes tagged with "SEO."


texts: Vertical sliding panel module for Drupal 7

texts:
Has anyone written a contrib module to place a block inside a sliding panel like this: http://spyrestudios.com/demos/sliding-panel-left/ . So i do not need to reinvent the wheel.

If not, i will write one :D


texts: How to upload file from a custom module?

texts:
I am trying to create one basic module for Drupal 8, where I have added one form with some textfields and multiple file upload element.
Now on "submitForm" I am saving textfields values on database, but I am not sure how I can save image fields. I will be only saving the filename in the database.

Will it be using same function as we have in Drupal 7?


texts: how do I disable modules in commerce kickstart

texts: I thought I needed dashboard and block languages modules for blocks. I enabled them and now want to disable them again but the update button has been replaced with an install button on the site settings -> modules admin page. How do I disable them?


texts: How to set form type as 'hierarchical_select' programatically?

texts:
I am using the following code to create a form in Drupal 6. This code displays a drop down filter with which I can select the terms, and apply the filters using the GET method.

function sample_create_form () {
  $vid=2;
  $options = taxonomy_form($vid, $value = 0, $help = NULL, $name = 'sample');
  $form['#method'] = 'get';

  $form['option'] = array(
    '#type' => 'select',
    '#title' => t('Terms for the Website'),
    '#options' => $options,
    '#description' => t('Website category'),
  );

  $form['submit'] = array(
   '#type' => 'submit',
   '#value' => t('Submit'),
  );

  return $form;
}

I want to display the form as a Hierarchical Select type. I tried to use 'hierarchical_select' instead of 'select' in the above code but it didn't work.

Is there a way by which we can get the hierarchical select form?

I am using Drupal 6 and I have hierarchical select module enabled.

Any help highly appreciated.


texts: Rules + Button Field: getting entity object to a custom action

texts:
I am using Rules 7.x-2.2 with the latest version of Button Field (http://drupal.org/project/button_field), Session API (http://drupal.org/project/session_api) and a custom module to store some entity values in a user's session when they click a button.

To clarify, I have an entity type (Commerce product) with an HTML instance of the button field that is supposed to trigger a custom defined rules action, where I want to extract some values from the entity object that the button is associated with.

This is how my Rules action info looks currently in my custom module:

function commerce_custom_box_rules_action_info() {
    return array(
        'commerce_custom_box_add_to_box' => array(
            'group' => t('Commerce Custom Box'),
            'label' => t("Add the product to the user's box"),
            'parameter' => array(
                'entity' => array(
                    'label' => t('Product entity'),
                    'description' => t('The entity the clicked button is attached to.'),
                    'type' => 'entity',
                ),
            ),
        ),
    );
}

And here is how my rule looks:

The problem is, in commerce_custom_box_add_to_box() (the function fired by my custom action), I have tried using dpm() on all of its arguments and none of them contain any entity properties, field values, or anything else that could even be remotely useful. All I get are empty "EntityDrupalWrapper" objects and similar. However, if I replace the action in the rule with "Execute PHP Code", there is an $entity object available there and dpm() reveals that it is in fact populated with all the usual properties.

Naturally I am trying to figure out why that object is there but isn't being received by my custom action. Perhaps I'm thinking about it in the wrong way?

A fresh pair of eyes on this would be hugely appreciated! Happy to provide more info if needed.


texts: How to hide core fields in Content types?

texts:
Drupal-6

I created a content type and added some fields. I can manage how to show them in Diplays Field. But there are some 'core fields' which I can not hide in Displays Fields.

I need to hide the 'menu system field'. Can I do this? How?
It would be great to hide it just for an specific role.

I uploaded a picture to show what I mean.


texts:
Can anyone please guide me how to remove the title of the Taxonomy terms.

I would like to give the title along with the description so i want to remove the default title.

Thanks for your help


texts:
Is there a way to automatically log out users when they close a browser?
I've tried to set (settings.php)

ini_set('session.gc_maxlifetime', 0);
ini_set('session.cookie_lifetime', 0);

but this doesn't work. Seems to me like it has anything to do with the 'sid' stored in the 'sessions' table?


texts: How to programmatically clear/refresh module file cache?

texts:
I'm maintaining a module, and have reworked the file structure of the module to make it more... modular.

In the update functions, some of the new files are referenced, but Drupal isn't aware of the new files until the cache has been cleared. The files are included in the .info file.

Please can someone tell me how to get Drupal to refresh its list of the files in this module?

Thanks,

[Side note - quite surprised that hooks and cache aren't available as tags!]


texts:
I'm adding external JS in my Drupal 8 site (//cdn.leafletjs.com/leaflet-0.7.2/leaflet.js) and I cannot seem to weight it using hook_js_alter. I can weight it if I throw it in a themename.libraries.yml file but then it gets rendered in every page. Ideally I want to only render the script in the home page. So this works:

function MYTHEME_js_alter(&$js) {
  if (drupal_is_front_page()) {
    $leaflet = '//cdn.leafletjs.com/leaflet-0.7.2/leaflet.js';
    $js[$leaflet] = drupal_js_defaults();
    $js[$leaflet]['data'] = $leaflet;
    $js[$leaflet]['type'] = 'external';
    $js[$leaflet]['every_page'] = TRUE;
    $js[$leaflet]['weight'] = -100;
  }
}

... but it weights it last and I'd like to weight it so it loads much earlier.

if I load it via a theme.libaries.yml file, it weights it lower but it renders on every page.

MYTHEME-corescripts:
  version: VERSION
  js:
    //cdn.leafletjs.com/leaflet-0.7.2/leaflet.js: {}
    js/scripts.js: {}

I'm open to this method if I could somehow add context to the YAML file to indicate only fore the home page.


texts: How to assign value from one file field to another programmatically?

texts:
I have a webform which have a file field. In the user profile I have also created a file field.

I am using the webform for user registration So I am assigning the values from the webform to the user profile fields programmtically on webform submit.

But I am unable assing the uploaded file in the webform to the user profile file field.

I am using the following code for assigning the file.

  $user->field_user_file['files']['und'][0]['value'] = $form_state['values']['submitted']['field_webform_file'];

but it did not work.

Any Idea what should I do for this?


texts: limit custom html.tpl.php to exact page, not subpages, drupal 7

texts:
I have a custom tpl page intended for a specific page like so:

html--something--anotherthing.tpl.php

This allows some custom handling on the page /something/anotherthing as desired. Unfortunately it is also being applied to sub pages like /something/anotherthing/details where the custom handling is not desired. Is there a syntax for naming tpl files so that it only applies to the desired page?

edit: I've enabled theme_debug and it suggests exactly what I already have for the filename so not helpful.


texts: I would like to know the difference between user/login and system/connect.


texts:
I created a custom service with mymodule_services_resources and I'm calling a function to return some items. This function inside is calling a view with views_get_view. The problem is always return an empty array.

If tested the same code somewhere else it shows the right results, but it does not work with services. I have something like this:

$view = views_get_view('the_view');
$view->set_display('default');
$args = array("my_param");
$view->set_arguments($args);
$view->pre_execute();
$view->execute();
$view->result; //empty array in the WS

I tried loading the admin user ($user = user_load(1); ) before calling the view but I had the same results.

Is there something I should add, change or remove in order I can get the results of a view calling service endpoint?

Thanks!


texts: How do I add an OR expression between two ->addExpression() in Drupal 7

texts:
I am trying to return flagged content that is either flagged as a favorite or flagged as visited. I can get them to return but i believe Drupal is doing an and between the 2 addExpression() in the query because it is only showing results if either both are flagged. Not one or the other.Here is my code. This is being used for the Drupal Services module to return some values. Any help would be greatly appreciated.

$query->leftJoin('flag_content', 'flag', "n.nid = flag.content_id AND flag.uid = $user->uid");
$query->addExpression("flag.fid is not null AND flag.fid = 2", "is_flagged");
$query->addExpression("flag.fid is not null AND flag.fid = 3", "is_visited");


texts: How to disable obligated address fields in Drupal Commerce in checkout?

texts:
In D8 drupal commerce there is a step after the customer selects checkout.

Left in the screen is de payment information which contains a form with:

Country
Company
First name, Last name
Street address
Postal Code
City

We only want :

Country
First name, Last name

I created a hook_form_alter but retrospection of the form gives me no clue which field I can adjust.

Also I checked in the profile if there are any options and I could not find them?

Any suggestion


texts:
I need to print a particular field I have added to my basic page content type, I want this field to appear on every page, the name of my field is 'field_featured_image' I have tried a few different methods and nothing seems to output my field.

I thought it would be as simple as this, however no such luck


texts:
Drupal 7 to 8 Migration works only on the core, thus doesn't inlcude 301 redirects created in D7 with the Global redirect module.

Is there a workaround to migrate all the 301 redirects to Drupal 8 instead of coping them manually (after the site itself migrated successfully from D7 to D8) ?

The reason I ask this is because if I won't migrate these redirects, search engines that already indexed the old paths, will show 404's and these pages' SEO will most likely damage.


texts:
I'm attempting to modify the language switcher links in a block so that the items are properly nested per my site's menu structure.

Currently, it outputs:

English Link

Japanese Link

Spanish Link

I need:

English Link

Japanese Link

Spanish Link

The $build['content']['#links'] array contains:

array (size=4)
  'en' =>
    array (size=5)
      'url' =>
        object(Drupal\Core\Url)[14062]
        ...
    'ja' =>
        array (size=5)
          'url' =>
            object(Drupal\Core\Url)[14062]

How can I modify this array so that elements are nested in a ul under the first link?


texts:
How to get the currently logged in user's roles in Drupal 8 ?

For example in D7 we have $GLOBALS['user']->roles;


texts:
I have a custom table in drupal 6 in which file path is stored in the field like sites/default/files/file_name.jpg. I dont have fid for this field.

How can I map this with my image field?


texts: Hooking into updates to an entity reference field within Parent node

texts:
Let's say I have a Structure Content type called "Fruit", and it only has a title.

And I have another Structure Content type called "Color" which is a dropdown menu with a few colors in it.

And i have an "entity reference" for Color on Fruit. So when I go to add a new Fruit, I can input in the Fruit title field "Apple", and then choose from the Color dropdown menu "Red".

I have a hook for node_update() which triggers when I change the Title of the Fruit. But when I change the Color, this trigger is not executed.

Which hook should I use if I want to track the Color changing on a Fruit?

This is for Drupal 7. Thanks so much in advance for your time and insight.


texts: views-view-field.tpl.php - How to print multiple values?

texts:
I've created a views template (based on views-view-field.tpl.php) because I want to exclude a certain value ('o') from being displayed.  I came up with the following code:

$data = $row->field_my_field;
$raw_value = $data[0]['raw']['value'];
$rendered_value = $data[0]['rendered']['#markup'];

if ($raw_value == 'o') {
}
else {
  print $rendered_value;
}

This works fine for a single value, but this field allows for multiple values (up to about 20).  How can I modify the code to print all of the values except, if present, 'o'?


texts:
I would like to extend the schema of another module's ("Rooms") database table.

I have my own module for alterations of that module (specifically the Rooms-module)

Rooms has "Options" with Name, Value..etc...

I want to add "Description" to Options.

My question:

is it possible to alter the database-table of another module..??

How would I start to change this?


texts: override the HTML of a single menu block

texts:
Good day all.
I'm new to drupal, and I could use a little help.
I got the override idea, and I try to stick to this, now, I have a menù, on the upper part of the site, that needs a different HTML from the other ones.
So, first of all, I've overridden the block tpl by adding a file called:

block-menu-menu-istitutional.tpl.php

but if I take a look at the block.tpl.php all I got are two simple prints:

<?php print $block->subject; ?>
<?php print $block->content; ?>

What I need is to change what is printed in $block->content to add there a markup different from all the other menu blocks.

may someone point me in the right direction? is this the case to override the preprocess function? but maybe in this way I'll change all the HTML of all the menu blocks, isn't it?


texts: Programmatically render an imagefield in Drupal 6 as defined in content-field.tpl.php

texts:
What sounds like simple task in the first place, has taken me hours without getting a solution: All I want is to render single values of an imagefield just as in the normal node, i.e. as defined in content-field.tpl.php. This is important for me, because there I add captions from the Imagefield Extended module

I tried with content_format(), but with the "default" formatter it gives me just an icon and a link and with the "image_imagelink" formatter from the imagefield.module I get an image, but not as defined in content-field.tpl.php and in the node type's display settings:

print content_format('field_image', $vars['node']->field_image[1], 'default', $vars['node']);
print content_format('field_image', $vars['node']->field_image[1], 'image_imagelink', $vars['node'])

I have tried a couple of other things and searched for hours, but I cannot find an answer. Any ideas how I can render the image "just the normal way"?

The HTML out I want is a defined in the template something like this:

Caption Text

            Source:
            Source text

            Licence:
            Licence text


texts: Custom error messages on search result page

texts: i have a drupal 6 multi language site with languages English and Arabic. In Arabic version i want Arabic error messages on search page. How can i do this?.


texts:
When im trying to add new node it gives me Error : The website encountered an unexpected error. Please try again later.

When I checked in Reports. I got this.

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'revision_id' in 'where clause': DELETE FROM {metatag} WHERE
  (entity_type = :db_condition_placeholder_0) AND (entity_id =
  :db_condition_placeholder_1) AND (revision_id =
  :db_condition_placeholder_2) AND (language =
  :db_condition_placeholder_3) ; Array ( [:db_condition_placeholder_0]
  => node [:db_condition_placeholder_1] => 133 [:db_condition_placeholder_2] => 133 [:db_condition_placeholder_3] =>
  und ) in metatag_metatags_save() (line 559 of
  /home/public_html/sites/all/modules/metatag/metatag.module).

Im using
Drupal 7.31
Metatag 7.x-1.0-rc2


texts: Session variable lost after setting it in ajax call

texts:
In my custom .js code included into administration panel via my custom module I have AJAX call:

... //call this on click or sth
jQuery.post("sites/all/...mycustommodule/ajax/here.php", function(result){ alert(result); }

And here.php defines some custom session variable:

<?php
sesssion_start();
$_SESSION['test_module_test'] = 'test';
echo $_SESSION['test_module_test'];
?>

When I hit here.php with POST request thanks to my .js code I get alert with session variable outputed:

  test

But then, when I try to print_r($_SESSION['test_module_test']) inside my custom module code, I always get some session variables, but without my test_module_test:

Array
(
    [views_seed_time-...] => 1482412682
    [views_seed_name-...] => 1482412682
)

I don't know if the session gets destroyed in between or there's something else going on here.


texts:
I am attempting to add/link a site map to my main menu. when I enter the path "sitemap" as the "path" for the link to the main menu, I get the following error:

  The path 'sitemap' is either invalid or you do not have access to it.

After searching for hours I cannot find a solution. Could someone please help me with a solution?


texts: Programmatically get the product name from $order

texts: I need to get the product name using the $order variable in Ubercart. How can I achieve?


texts: Drupal file manager that shows relations to content

texts: Is there module or simple way to show file relations to content with file manager like elfinder or any other? I am using Drupal 7.


texts: Deadlock found in domain source Node Insert .- Drupal7

texts:
Possible Duplicate:
  Deadlock issue on my server

  PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO {domain_source} (nid, domain_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array
  (
      [:db_insert_placeholder_0] => 362400
      [:db_insert_placeholder_1] => 2
  )
   in domain_source_node_insert()

Can you explain me why this error happens?


texts:
I want to add Lightbox2 from http://lokeshdhakar.com/projects/lightbox2/ to my page, but following instructions (adding a JavaScript, and a CSS file) doesn't work.

I thought I did all correctly, but when I click on the image, it doesn't show any popup.
What's wrong with it?


texts: File structure of libraries folder and detection of module external plugins

texts:
The module CKeditor anchor link require a CKEditor plugin.
Can this plugin be placed in subfolder of the /libraries folder or does it have imperatively to be placed at the root of /libraries ?
More generally, does drupal parse recursively the libraries folder when intenting to detect external plugins ?


texts: HTML comment based tokens in hook_views_post_render()

texts:
I am trying to figure out why my HTML comment based tokens are not getting replaced in hook_views_post_render(). I have a view where I've got a couple of fields, let's say, nid and the content title. I want to replace the title with something else.

So, I've edited the content title and checked the box to rewrite the output of the field and added something like this:

<!--something-->

Now, in hook_views_post_render() I am doing this:

strtr($output, array('<!--something-->' => 'my changed output');

But the problem is, nothing happens. For some reason, $output doesn't have the HTML comment, it's like it is being stripped out. I have specifically looked at the options for the field in my view and I don't have any of the checkboxes checked that strips out the HTML. I can add other html in $output and they all work fine, so there is no problem with the html going through. So, I am wondering what the issue is. Would appreciate any help on this.


texts: Users can rate product after their order status changed to completed

texts:
I want to give permission to user to rate a product when their order status set to completed. For that I've tried using rules but in action i was not able to set permission for particular user whose order completed.

I'm using five star drupal module which is using voting api. Need help to implement this feature.


texts: Form errors cannot be set after form validation has finished. When trying to edit user password in webform presave hook

texts:
I'am trying to edit a user account based on the values submitted through webform, the webform is Ajax enabled and I'am using the following code to achieve this.

function hook_webform_submission_presave(WebformSubmissionInterface $webform_submission) {
  if ($webform_submission->getWebform()->id() == 'profile_edit') {
         $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
         $webform_data = $webform_submission->getData();
          if(!empty($webform_data['email'])){
              $user->set('mail',$webform_data['email']);
          }
          if(!empty($webform_data['password'])){
              $user->set('pass',$webform_data['password']);
          }
            if(!empty($webform_data['mobile_no_'])){
              $user->set('field_mobile',$webform_data['mobile_no_']);
          }
          if(!empty($webform_data['cover_photo'])){
              $user->set('field_cover_picture',$webform_data['cover_photo']);
          }
          if(!empty($webform_data['profile_image'])){
              $user->set('user_picture',$webform_data['profile_image']);
          }
          if(!empty($webform_data['user_name'])){
              $user->set('name',$webform_data['user_name']);
          }
          $user->save();
     }
}

what happens is when I try to edit any other field except the password field everything works fine, but if I provide a value in the password field I receive a 500 response with the following error message:

  The website encountered an unexpected error. Please try again later.LogicException: Form errors cannot be set after form validation has finished. in Drupal\Core\Form\FormState->setErrorByName() (line 1057 of core/lib/Drupal/Core/Form/FormState.php). Drupal\Core\Form\FormValidator->setInvalidTokenError(Object) (Line: 868)

The password field in the webform is of type password and there is no confirm password field.


texts:
I'm trying to add a checkbox column in the admin table part of my module.
The idea is to add checkboxes at the beginning of each row, like in the normal admin content management form.

My table is build in a form function with the following code :

function myform_admin_form($form, &$form_state) {

$query = db_select('form_xml', 'f');
$query->join('form_xml_status', 's', 's.id = f.id');
$query->join('users', 'u', 'u.uid = f.uid');
$result = $query
        ->condition('s.status', 'todo', '=')
        ->fields('f')
        ->fields('u', array('name'))
        ->execute()
        ->fetchAll();

$header = array(
array('data' => t('ID')),
array('data' => t('Name')),
array('data' => t('User')),
);

foreach($result as $key){
$rows[] = array(
array('data' => t($key->id)),
array('data' => t($key->name)),
array('data' => t($key->user))
);
}

$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
);

$output = theme('table', array('header' => $header, 'rows' => $rows));
$output .= $form;

return $output;

}

My tableselect doesn't display at all, but "Array" appears at the bottom of the table. Is it possible to add checkboxes in a table like this ?