texts: How to show different view templates for different taxonomy terms?

texts:
I'm using Drupal 7, and I had a vocabulary "Destinations". Under this vocabulary, I had terms with 2 levels. For example:

ASEAN
-- Brunei
-- Indonesia
-- Laos
EUROPE
-- Spain
-- Greence
-- Portugal

For all 1st level taxonomy terms of this vocabulary (ASEAN, EUROPE), I want to display them as a view, with child taxonomy. Eg:

ASEAN
-- Brunei  (term name & description)
-- Indonesia  (term name & description)
-- Laos (term name & description)
EUROPE
-- Spain  (term name & description)
-- Greence  (term name & description)
-- Portugal (term name & description)

For all 2nd level taxonomy terms, I want to display nodes which have the term. Eg:

Brunei
-- Package 1
-- Package 2
Spain
-- Package 3
-- Package 4

Is there any way I can configure the views to display result as above?
It might have something to do with contextual filter, but I don't know how to configure the parameters.

Any idea on how to achieve this?


texts: Why does Drupal 7 prefer CSS @import rules to  tags?

texts:
"Don’t use @import," lots of guys say.

There are lots of shortcomings of using @import.

Using @import within a stylesheet adds one more roundtrip to the overall download time of the page.
Using @import in IE causes the download order to be altered. This may cause stylesheets to take longer to download, which hinders progress rendering making the page feel slower.

Why does Drupal 7 use it?

I want to change the @import rules to <link> tags. How can I do this?


texts: How to run Drupal console command from code?

texts:
I have found a lot of documentation on how to run Drush commands from code, but I'm specifically looking on how to run a Drupal Console command from code.

I have some experience in Symfony and I know how to run a Symfony command from code. Since a Drupal console command extends on Symfony command, I thought this should be rather easy. Simply following this tutorial doesn't amount to anything though.

I am trying to run a command in a hook_cron() implementation in a custom module.


texts: How can I add multiple modals to a site?

texts: Of course there are many ways to add modals, I've been sandboxing a lightweight method leveraging ctools; but how would I add several distinct modals to a site? I have thought about making a modal content type, which could then have many instances, but I'm not able to imagine how to get node content in modals in a way that I could then use contexts to show them in various parts of the site. I'm wondering if the community has any insights here.


texts:
I am new to drupal 8 and i need to override a views template. So, for that I have enabled theme debug in services.yml to view the twig template suggestion name.

This is my view theme debug.

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_unformatted__test_content_view' -->
<!-- FILE NAME SUGGESTIONS:
   x views-view-unformatted--test-content-view.html.twig
   x views-view-unformatted--test-content-view.html.twig
   * views-view-unformatted.html.twig
-->

Then, I created the file in templates of drupal8 theme and the theme file calls. I used themename_views_view_unformatted__test_content_view() function to override in themename.theme file but the function doesn't called.

Is there anyway to override the variables coming to the twig template. Can anyone give me suggestion to override the views template.

Thanks in advance.


texts: Drupal Commerce: Print order for warehouse

texts:
I followed Drupal Commerce: Print order? solution:

  Through Rules you can achieve this by creating a Rule within the Rules
  module:

  First step create a custom rule at
  /admin/config/workflow/rules/reaction/add Select the React on event:
  "Completing the checkout process" Add a new Action: "Send mail" Once
  you add the email addresses from/to, than add the replacement fields
  in the body text of the email. I suggest:
  [commerce-order:order-number], [commerce-order:type],
  [commerce-order:commerce-line-items]. But you can figure that part
  out. Save your Rule.

I receive the email but I do not have a proper list of ordered products, instead I have numbers. One per article but the change on each order even if the articles are the same.

How can I have a proper order listing in the email?


texts: Views with manually position of content type item and load more

texts:
I have to content types "article" and "jobs" and i'd like to create a view where i can say on position 1 is the newest article, on position 2 is the second newest on position 3 is the newest job and on position 4 is the second newest and so on.

i think manually sorting or positioning is not an option, cause i want to use the load more function.

is there a way to handle this?

best regards

UPDATE:

to prevent missunderstandings: it should look like this:

-- 1. article --
-- 2. article --
-- 1. job --
-- 2. job --
-- 3. article --
-- 3. job --
-- 4. job --
Load more
-- 4. article --
-- 5. job --
-- 5. article --
-- 6. article --
-- 6. job --

so i think

  sort criterias

are not an option


texts: How to get path of an element of a kint printed array?

texts:
In D7, when you used DPM to print out an array / object, you could double click each line to get the "path" of the element (like: ['#target']['tid']). In D8 am totally missing this feature.
I also saw on a site where I can see this feature. But my "stable" devel module just doesn't seems to have this feature. Am I missing a config issue?


texts: How can I prevent Drupal from stripping/sanitizing anchor tag

texts:
In a custom moudule I find email addresses  and return them as clickable mailto anchors on the page.

    $tableEntry['Email'] = l($emailAddress ,'mailto:'.$emailAddress , array('html' => TRUE));

    //Snippet of render array being used to create the table.. In a different function from the line above
    $rows = array();
    foreach ($tableEntries as $entry) {
    $rows[] = array(
        array('data' => $entry['Email']), //l($entry['Email'], 'mailto:'.$entry['Email'], array('absolute' => TRUE))),
    );

If i create the anchors before passing them into the table's render array, Drupal does something to strip away the html.
I have tried a whole bunch of argument options in l() and have also tried directly entering in HTML into l(), all the time the results get stripped. (I always check the generated email address to be sure it was first created successfully) .
The only way i am able to get an anchor to display as a link within the browser, instead of plain text, is to call the l() function at the last step of building the table render array eg. the commented out code. Any explanations are much appreciated.


texts: How do I get the user name of the user profile page that is being visited?

texts:
I created a module and I need to use the user name of the user's profile being viewed.

How do I call/get it?


texts:
I am using git to track my commits in a Drupal 7 site. I was involved in a project which uses git to move between production and development server. I made some changes in features and pushed it to the production server. I now notice the following error:

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

I am sure this is because of some feature errors, but at the same time I am not sure what feature caused this to happen.

I want to know is there a possible way to remove the commits by date. Like remove commits from 25th may? or Set header before 25th may?


texts: Which module creates the "Article" and "Basic page" content types?

texts:
By Default we have two content types: Article and Basic page.

Which module creates those content types?


texts: Taxonomy Term description in views when "no results" (Haven't associated nodes)

texts:
need help with Taxonomy Term description when no results in views.
I'm using Drupal 7.44 / Views 3.14 and render content from node teaser template without using fields, and for showing description used Header area / Global:Text area / Php Filter and this code

<?php
$view = views_get_current_view();
if (is_numeric($view->args[0])){
$term = taxonomy_term_load($view->args[0]);
return $term->description;
}?>

But it's work only when term have associated node, but some terms doesn't have nodes and description not showing.

Maybe some one knows how can I fix it?


texts: jquery cannot hide span attribute in Drupal 7

texts:
What is wrong with this jQuery code and why can it not hide the span attribute?

jQuery(document).ready(function($){
    $('span.fieldset-legend').hide();
});

Heck, just trying to hide the entire span and it still does not work!

jQuery(document).ready(function($){
    $('span').hide();
});

If it helps, I am trying to hide a horizontal item in a horizontal group.

I can confirm that my jQuery is generally working.  For example, the below works fine

alert('test');

This also works fine

jQuery(document).ready(function($){
    $('p').hide();
});


texts: What is the recommended jQuery and jQuery UI version?

texts:
What is the recommended version of jQuery and jQuery UI that I should use on a Drupal 7.77 site?
I know the latest jQuery version is now 3.5.1, but what is the recommended version for a Drupal 7.77 site?


texts: How to reference a Current Node URL Prior/After a User submits a Rules Link trigger

texts:
Maybe I'm way off mark here.
I have an Node 'application' page and require that the current view page be referenced within a following page after a logged in user has clicked the 'Apply' link (a Rules Link). The above node allows a user to apply for an advertised role say a musician for a bands project guitarist vacancy, but basically its like any other Jobsboard type process.

I can get my Nodes related with the Relation model, but that's not the issue. The issue is that I need to get the relation of the current viewed page so that once the User applies, the said Node will be referenced for later recall in any applicant or Advertiser's dashboard. At the moment, all that happens is that the Rules link takes an Applicant user to a custom vacancy complete form page (which I have made using Panel Pages) and it fires off fine, but there is no link to either parties involved for me to then manage back-end and build further functionality on.

I want to grab the Job Node URL so that after a user hits an 'Apply' Rules Link button (shown on the Job node page bottom) it then makes a note of the said Node (URL) so that a number of Rules Actions such as create a new Node number; create a relationship to the Applicant; saved a new entity as an Application Node. I can manage to get the 'Submit' to trigger to the application page, and 'send it' but I'm not sure at what stage or where temporarily the said Node url path needs to be set prior to Rules then taking it and working through it's Rules actions (ie, post application, send email to application, send message to Advertiser you have a 'new' applicant whereas after they can do further tasks (outside of this question posted here).

Or, maybe my approach is completely off goal. Maybe the only important point is to get the Rules Link to relate to the currently viewed Node (job position in question offered) which when triggered will then relate the user to any other uses. I'm not sure, but even looking at first loading any Node, is it possible that the Rules Link has to already pull in the Node ID once the user clicks to view the Node on screen, then the Rules Link will have already built a relationship?

Hope the above is not too confusing! but I've tried to express my mental ideas. I would like to do this in Rules. (I'm using Rules, Rules Link, Views).

Failing all of that, how do I link in a User application to relation to the original post so that the advertiser can see who has applied to the said vacancy advertised?

Please, where am I going wrong in my approach and what am I missing?
Much appreciated. Thanks.

Revised question: 21/05/14.


texts:
I've been trying to figure out why the pager element for views won't show up for anon users in Drupal 7. The following are the things I've tried to get them to show, cache clear, mess with the access param in the actual view, create a function that calls

drupal_static_reset('user_access');
drupal_static_reset('user_role_permissions');

Has anyone been able to solve this? I've searched Google for over an hour for a fix/explanation.


texts: Drupal 8: Pdf (print) search results (search_api)

texts:
I am using the Entity PDF plugin in Drupal 8, that does a good job in exporting to PDF nodes, but seems to exclude other scenarios such as Search Result list.

Anyone can provide some hints how would a PDF export be implemented for  search results?


texts: Openid account validation without password reset

texts: I enabled Openid, and installed the OpenID selector module.  When a user logs in via openid, they have to validate their email, and the way to do so is by drupal sending them a one-time login link to reset their password.  Is there any other way to validate the email address?  Sending a password reset link is confusing for users.


texts: Add custom ajax command to ajax response after webform is submitted

texts:
What I'm trying to do is to invoke some javascript after a webform is successfully submitted by ajax.

To do that I followed this advice and created an EventSubscriber to intercept ajax response and add my custom command there. The problem is that on some reason I can't check if the webform is submitted (data are sent) or not.

  public function onResponse(FilterResponseEvent $event) {
    if($event->getResponse() instanceof WebformSubmissionAjaxResponse &&
       $event->getResponse()->getWebformSubmission()->isCompleted()) {
         $event->getResponse()->addCommand(new MyCustomCommand());
    }
  }

The problem is in isCompleted() method which always returns false on some reason. Actually I checked other methods from WebformSubmissionInterface and in this my event subscriber this WebformSubmission entity always looks empty (getters return nothing) and geState() always returns "STATE_UNSAVED" not depending if a webform is successfully sent of failed on validation.

What I'm missing? Is anything I'm doing wrong here? Or maybe are there any other method to achive same goal?


texts: Where are classes in a module's `$classes` variable set?

texts:
I am new to Drupal. I am styling a theme, but have noticed there are some classes affecting a module's layout.

When I examine the module's .tpl.php file I find:

<div class="<?php print $classes ?>">

Which is where the classes I want to alter are appearing.

I tried looking for where this is set by editing the page, clicking on the little gear icon for that module and having a look at the CSS properties option, but this was empty.

I then looked at the module's settings themselves, but there are no options there to set styles.

Would anyone know where this $classes variable is set?


texts: Drupal 7 Fields, when adding an existing field during content type creation, how to tell where else its used?

texts:
I just realized that if you use an existing field that is used in another content type and you change the field settings, you end up changing it on the other content types that share the same field. Is there a way to tell where else an existing field is being used?

Example: I have a field called "field_image" and using it in my basic page content type. Now I use it for my blog content type. How can I tell my basic page content type was using that same field?


texts: Recommended modules for managing Content access?

texts:
I am looking for an access module.

Probably, the most popular is the Content Access module. But what modules are exist for that as well?

Also, when it says I have to rebuild the links (or permission, I don't remember) right after installation, what exactly does it do?


texts: How to display custom block anywhere in a div?

texts: I am creating one drupal 8 theme based on bootstrap framework, for banners I created one custom block, named as 'Homepage banner', without creating any region, how to display this on my homepage template 'page--front.html.twig'.


texts: How bad is it to use Node_load in a loop in drupal 7?

texts:
Something like:

for ($i = 0; $i < 100; $i++) {
    $node = node_load($i);
    print $node->fieldYouWant;
}

That is a lot easier to read, gives you access to all the fields etc. However, in a loop, I would imagine Drupal would fall over? Or is the built in caching sufficient to not have to worry about it?


texts: Bootstrap Views Grid Unable to specify Medium and Small device classes

texts:
I am currently using https://www.drupal.org/project/views_bootstrap and successfully created a Bootstrap Grid

For each grid item I get the following output as the root most div tag

But I need to add more class names as follows

is there a facility to provide additional classes which needs to be added in the root component of each rendered view content?


texts: How to allow any file extension (or use a blacklist instead of a whitelist) for file fields in Drupal 8?

texts:
For a file field, it’s required to enter file extensions in "Allowed file extensions".

Is there a way to allow any file extension? Or a way to switch from a whitelist to a blacklist?

What I found

For Drupal 7, there is the module Allow All File Extensions. A Drupal 8 port doesn’t seem to be planned.
For Drupal 7, there is the question How to allow for files of any extension to be uploaded?, where the module mentioned above is recommended.
For Drupal 8, there is the issue Not possible to allow uploading files with any file extension, but it seems to be inactive.


texts: What is the correct way to render content from custom content type?

texts:
I am new to Drupal and am realising that there are a number of ways to perform even the most basic task but it is hard to know which way is right.

When rendering fields from a custom content type which of the following ways is correct/most efficient/safest way or am I wrong and there is another even better way?

Option 1 - this way seems a little verbose but I have read in a number of places that this is the correct way to render individual fields.:

<?php $included = field_view_field( 'node', $node, 'field_what_s_included', array('label' => 'hidden') );
            print render($included);
        ?>

Option 2 - This way seems much neater and is also written about a lot:

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

Thanks for clarifying this for me.

James


texts:
I recently come across a issue where my page was rendering two boostrap.js (Offcourse bad coding). An external Js from a module and another js from twitter bootstrap theme. Its causing some of the other js library to stop working(say bootstrap.multiselect.js).  So thought of removing the one of the js by mytheme_js_alter. Below code is working fine to achieve what is want, but with one execption. Sometime its does not work, and after clearing the cache it starts working.

function mytheme_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
  $current_path = \Drupal::service('path.current')->getPath();
  $current_uri = \Drupal::request()->getRequestUri();
  if ($current_path == '/node/777' || $current_uri == '/mypage') {
    $external_bootstrap = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js';
    if (array_key_exists($external_bootstrap, $javascript)) {
        $javascript[$external_bootstrap]['data'] = $javascript['https://cdn.jsdelivr.net/npm/bootstrap@3.4.0/dist/js/bootstrap.min.js']['data'];
unset$javascript['https://cdn.jsdelivr.net/npm/bootstrap@3.4.0/dist/js/bootstrap.js']);
    }
  }
}

Has anyone faced same issue of caching? Please suggest any solution to overcome this.


texts:
My Drupal site has been compromised.

Although I applied all modules updates and update my Drupal core to 7.35, it is still compromised.

What would the next logical step to take be?


texts: How do I remove all references to the Sample DB when using the Forena reports module on a server without PDO Sqllite?

texts:
We have Forena installed on a server that doesn't have the PDO driver for Sqllite and would like to remove all references to the Sample DB repository so that Forena pages don't display an error about the missing driver. The users see a lot of:

PDO driver support for sqlite not installed

I first tried removing permissions on the SampleDB repository as mentioned in one thread in the issue queue. This had no effect and the error message was still displayed.
I have tried using drupal_alter to remove the repos:
function mymodule_forena_repos_alter(&$repos) {
  if(isset($repos['forena_help'])){
    unset($repos['forena_help']);
  }
  if(isset($repos['sampledb'])){
   unset($repos['sampledb']);
 }

}
I then get a new error:

Undefined repositorysampledb
Undefined repositoryforena_help

I have tried patching the Forena module to unset the settings.php variables inside the sampledb folder. That also gives a new error along the lines of "PDO Driver not found".
How do I remove all references to the SampleDB repo? I would also like to remove the Forena Help and Drupal Admin repos if possible.


texts: File browser setting IMCE in CKeditor (using Wamp)

texts: I am using wamp for local testing. I installed drupal 7.12, added CKeditor module and IMCE. In "Settings" for CKeditor i am trying to set the "File browser" options to IMCE (IMCE is one op the options i can choose) but after hitting the "Save"-button i got a message telling me that the page has been re-initialised during loading of the page and ask me to check firewall settings and or i have internet connection. Of course my firewall settings are OK and i also have internet connection. It seems that IMCE (or CKeditor) is the only module causing this kind of problem; all the other modules are installing just fine and changing settings is no problem


texts:
My module adds further content to a specific node bundle, in the "view" phase, in the following way:

hook_view (under the right conditions) adds these "contents" to the node display array
hook_theme specifies how to render the possible render_array related to the added contents

I followed several tutorials about, and in effect the documentation (of the latter) reports:

  The structure of $node->content is a renderable array as expected by
  drupal_render().

Here is an abstract from my code:

/**
 * Implements hook_view().
 * Remember: hook prefix is based on the base of the node type (node-type-specific hook)
 */
function mynode_view($node, $view_mode) {
  $contentWrapper = entity_metadata_wrapper('node', $node);
  $myfield = $contentWrapper->myfield->value();
  if ($view_mode=="full") {
    $node->content["ds_column"] = array(
      '#markup' => theme('ds_column', array(
        'element' => _mymodule_to_render_arrays($myfield, $node->status),
        )),
      '#weight' => 150,
    );
  }
  return $node;
}

As you can see this adds the ds_column to my node content, telling me it has to be rendered by a theme function.
It also passes to the theme function a "render array" (containing the information to be rendered).

/**
 * Implements hook_theme().
 */
function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'ds_column' => array(
      // See http://drupal.org/node/224333#theme_changes
      'variables' => array('element' => NULL),
      'template' => 'theme/ds_column'
    ),
  );
  return $theme;
}

This part of my module explain what template file have to be used in order to properly render, in the node (bundle) page, the content I added by the previous hook.

For what I see this is the standard approach. And indeed everything works fine.

The problem description starts here.

The module I described has been installed on an environment using the Display Suite module to define how to show contents for each node type in the node page, but the Display Suite module doesn't allow to see, in the configuration page, the content I added with the code shown above. So now that content doesn't appear in the node page.

I would like just to see the "ds_column" in the Display Suite configuration page for that specific node, in order to place it properly.

I can't figure how to see it (have I to implement also a DS hook? Have I to modify my code in some way?). I just found the "Display Suite Extra" sub-module, but I wasn't able to solve by it.


texts: How do I remove the "where" clause from a structured query object in hook_query_alter()?

texts:
Jumping off of this question, I'd like to know how to gracefully detect and remove each snippet in the WHERE clause of my query object in plain old hook_query_alter(), not hook_views_query_alter() (as the Views query object seems structured in some entirely different way (frustrating!).  The documentation vaguely suggests that this is possible by showing how you can create a reference to your query conditions that you can then manipulate, by starting with this:

$where =& $query->conditions();

... but the object(s) within are utterly confusing, and I've been struggling to remove or replace existing snippets.  I've explored /includes/select.inc and /includes/query.inc but the classes therein don't seem to provide any methods for fine-tune manipulation.


texts: drupal 7: create a list of ajax submit inside another ajax submit callback function

texts:
I have one ajax submit with its callback function, I need when I click on this submit add a list of submits with its ajax callback

My code in my module is:

function MYMODULE_form($form, &$form_state) {

$form['maindiv'] = array(
'#type' => 'container',
'#id' => 'maindiv',
'#attributes' => array(
  'class' => array('maindiv')
  ),
);

$form['maindiv']['submit1'] = array(
      '#type' => 'submit',
      '#id' => 'submit1',
      '#value' => t('create'),
      '#attributes' => array(
        'class' => array('submit1')
      ),
      '#executes_submit_callback' => true,
      '#ajax' => array(
        'callback' => 'submit1_callback',
        'wrapper' => 'maindiv',
        'effect' => 'fade',
        ),
    );

return $form;

}

function submit1_callback($form, $form_state) {

$form['maindiv']['listsubmit'] = array(
'#type' => 'container',
'#id' => 'listsubmit',
'#attributes' => array(
  'class' => array('listsubmit')
  ),
);

for($i=1; $i<5; $i++)
{
    $form['maindiv']['listsubmit']['deletesubmit_'.$i] = array(
      '#type' => 'submit',
      '#id' => 'deletesubmit_'.$i,
      '#value' => t('delete'),
      '#attributes' => array(
        'class' => array('deletesubmit')
      ),
      '#executes_submit_callback' => true,
      '#ajax' => array(
        'callback' => 'deletesubmit_callback',
        'wrapper' => 'listsubmit',
        'effect' => 'fade',
        ),
    );
}

return $form['maindiv'];
}

function deletesubmit_callback($form, $form_state) {

 //any code

return $form['maindiv'];
}

first submit work good , but whos created inside this submit callback function never apply ajax action, its referech the page without apply any thing .. what's wrong in my code?

thank you


texts: I want to send a confirmation mail on event of submit button in webform?

texts: I have a webform and a E-mail field in it Is it possible to have a confirmation mailed out to the person registering? (as in, is it possible to have the functionality also worked in?)


texts: Form API select list remove blank entry (default select an entry)

texts:
I populate an select list using the following code.

$getCompanies = 'SELECT nid, title FROM node where type = "my_type"';
        $companiesResult = db_query($getCompanies);
        $companyArray = array();
        $companyArray['empty'] = "";
        while ($data = db_fetch_object($companiesResult)) {
            $companyArray[$data->nid] = $data->title;
        }
        $form['company'] = array(
            '#title' => t('Type'),
            '#type' => 'select',
            '#description' => t(''),
            '#options' => $companyArray,
        );
    }

This gives me an empty result first. I want to remove this empty result. I tried adding #required by it does not add a default selection. What can I do to remove an empty element?


texts: Permissions not working with Tabs menus?

texts:
I have Menus with Tab structure Working from my custom module. But When I built permissions for each Tab It does not work according to assigned user roles in permissions, also it just made those url's not accessible. Please suggest what I am doing wrong, Thanks!

function my_module_permission() {
  $arr = array();
  $arr['access one_type_titles'] = array(
    'title' => t('Access First Type Titles'),
    'description' => t('Allow users to First Type Titles page.')
  );

  $arr['access second_type_titles'] = array(
    'title' => t('Access Second type Title page'),
    'description' => t('Allow users to access Second type Title page.')
  );

  return $arr;
}

function my_module_menu() {

  $items['type'] = array(

    'description' => t('Page for translation'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('custom_list'),
    'access arguments' => array('access one_type_titles content'),

  );

  $items['type/fr'] = array(
    'title' => t('French Links'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'page arguments' => array('custom_list'),
    'page callback' => 'drupal_get_form',
    'access arguments' => array('access one_type_titles content'),
  );

  $items['type/en'] = array(
    'title' => t('English Links'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'page arguments' => array('custom_list'),
    'page callback' => 'drupal_get_form',
    'access arguments' => array('access second_type_titles content'),

  );

  return $items;
}

Using 'access callback' => can_the_user_see_this_item, and then coding access according to user role make it works but not with above method.

function can_the_user_see_this_item(){
 if (condition....) ) {
    return TRUE;
  }else{
    return FALSE;
  }
}


texts:
I'm trying to display the number of total search results on my search results page, using the core search module. I've tried manipulating item-list.html.twig and item-list--search-results.html.twig by displaying items|count but when there are more than ten results, items|count only captures the number of results on that page.

I'm considering installing Search API and working with views, but that seems like overkill for this one little modification.


texts: How do I update a Drupal distribution to a newer version?

texts:
I am looking at using http://drupal.org/project/commons , but I am not sure how easy it is to update a distribution when a new version comes out.

Also, can I use drush to do it, or do I have to manually download and unpack the distribution?


texts:
How do I render a menu in a theme? Is there an easy way to do this?

I would prefer just a line of code that calls all the menu items in for a custom menu.

Say for example I had a menu named "brands"

How would I put that on my page--front.tpl.php?


texts: Submission handler for the user registration form doesn't work

texts:
I'm working on a Drupal 7 portal. I added a custom field to the registration form and I would like to get hold of custom field value when the registration form is submitted and before it is stored in the database.

I'm trying to use the submission handler for the registration form and print the content of $form and $form_state, but those values never get printed as message. I installed the Devel module as well.

function user_register_form_submit($form, &$form_state) {
    drupal_set_message('
'. print_r($form, 1) .'
');
    drupal_set_message('
'. print_r($form_state, 1) .'
');
    drupal_set_message(t('An info message from user_register_form_submit'), 'error');
}

I appreciate any input on what the issue could be.


texts: My current project requires the use of comments on submitted data on entityform. I believe this functionality is built in drupal 7 node. By any chance, is it possible to implement it also on Entityform? if not is there a possible workaround to meet my project requirements?


texts: Disable taxonomy terms in certain contexts or split into different vocabularies?

texts:
I have created a taxonomy of regions, with the intent of multiple uses:

Users select their region in their profile
Events include a region field.

This should make it rather easy to show users events in their region.

Each of these use cases requires one or two extra terms:

Users might be from "outside New Zealand".
Events might be "Nationwide", "Worldwide" or indeed "online".

But we don't want events outside NZ submitted, and the latter three terms are not appropriate for users to choose as their location. So I want to disable them from the listed options in each case.

I thought there might be a CSS solution as there are ample distinctive selectors available in the parent elements, but Drupal does not assign any classes to option elements - they only have a value, and the numeric id of the taxonomy term at that.

Is there a way to do this using Rules or Context?


texts: Programmatically changing the global site name?

texts:
I'm making a multi-site setup using the same install and the same database, basing it off domains. I'm trying to programmatically alter the site_name variable so that it displays a different site name based on the domain being used.

I am using 3 different methods to achieve this at the same time, however even that is not bullet-proof. Certain instances (i.e. some administration pages, user login, or user profile edit) still display the default site name in the page title (or elsewhere).

I am doing the following:

$conf['site_name'] = $my_title; in settings.php
$vars['site_name'] = $my_title; in my theme's hook_preprocess_page
using hook_tokens_alter in a custom module to change the [site:name] token to $my_title

Despite all these measures, it seems I did not enforce the site name change in a bulletproof way. Is there a better method I have missed?

Worth mentioning: I am using the Metatag module, which seems to alter page titles on a fundamental level. I am not sure if this is related to my problem.


texts:
I have order form with field reference number. when a new order is submitted i need to get the last reference number. I did something similar long time ago in Drupal 7 but now i need to do it in Drupal 8 and i don't know how. I noticed that fields in database are written as 'node__field_ref_number'

DRUPAL 7
$query = db_select('field_data_field_order_reference_number', 'f');
$query->condition('f.bundle', 'order', '=');
$query->fields('f', array('field_order_reference_number_value'));
$query->orderby('field_order_reference_number_value','DESC');
$query->range(0, 1);
$query->execute();
$result = $query->execute();
$record = $result->fetchAssoc();
//drupal_set_message('previous order №: ' .print_r($record['field_order_reference_number_value'], true));
$title =($record['field_order_reference_number_value']) + 1;
//drupal_set_message('order №: ' .print_r($title, true));
$form_state['node']->field_order_reference_number['und'][0]['value'] = $title;
$form_state['node']->title= 'reference number ' .$title;

So far i can get only nid of nods of that type (content_type_order)

DRUPAL 8
$query = \Drupal::database()->select('node', 'n');
$query->addField('n', 'nid');
$query->condition('n.type', 'content_type_order');
$results = $query->execute()->fetchAll();
drupal_set_message('value' .print_r($results, true));


texts:
I have a custom theme that I use in several websites.
My theme is on gitlab.
I can download my theme by composer in different websites.
My problem is when I update repository theme with a fix or new feature and then this do not mirror on websites, even if I delete theme folder and composer.json info, it's always stuck on the same version.
My composer.json of theme repository
{
"name": "test/test-theme",
"description": "Drupal Custom Theme",
"type": "drupal-custom-theme",
"minimum-stability": "dev",
"require": {}

}
My composer.json from the website:
"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "package",
        "package": {
          "name": "test/test-theme",
          "version": "dev",
          "type": "drupal-custom-theme",
          "source": {
            "type": "git",
            "url": "{URL}",
            "reference": "master"
          }
        }
      }
],
"require": {
    "test/test-theme": "dev",
 }

How can I update my theme last features with composer?


texts: How to delete a webform submission in a custom module?

texts:
I want to delete a webform submission from a custom module that I've written. I'm using webform_submission_delete(123, 76). The error I receive is:

  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 141 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Warning: Invalid argument supplied for foreach() in
  webform_submission_delete() (line 141 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 153 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).
  Notice: Trying to get property of non-object in
  webform_submission_delete() (line 157 of
  /Applications/MAMP/htdocs/mercury/sites/all/modules/webform/includes/webform.submissions.inc).

I'm a bit new to module development. Am I missing something?


texts: Available tokens in the Filter Section of Views

texts: Are any tokens(as nid) available in the FILTER CRITERIA of Views (see pic bellow). For example I can sort out all nodes with greater than the current NID...


texts: Content access based on on the field reference

texts:
I want to make a content access ( node ) based on it's user reference field .
ie: While i'm creating a node that have a user reference field, i want that it will be accessible just for the users that i mentionned before .
Is there any module or a way to do that ?
Thank you very much


texts: Best way to store not publicly viewable data?

texts:
I wanted to know what is the most suited to store not publicly viewable data? Here is an example what I want to achieve:

Imagine having a personal section about me. On this site I show the visitors an online CV which includes a section of my skills. In the section "skills" I have listed each skill with a specific rating like 8/10 depending on how good I'm in it.

For helping you to visualize it, here is a normal CV with a section skills:

https://creativemarket.com/GraphicsToll/492647-Resume

Now my question is how do I store this kind of data? I know that a normal custom content type would be an overkill because not one of the skills should be separately viewable, it should be only visible with all the other skills on my online CV. Further I looked into custom content entities but I think this also an overkill because you could also view each skill separately (canonical).

What other ways are there? Do I have to create a module which just interacts with the database abstraction layer?

I appreciate any kind of help!


texts: _preprocess_views_view not getting called

texts:
Drupal 7, Views, Bootstrap theme sub theme in use

I have a views-view-table.tpl.php file in my sub theme and I am trying to preprocess some of the variables sent to this tpl. I created a function bootstrap_preprocess_views_view(&$vars) in my template.php and it is not getting called when I visit one of my views pages. Why would this be? Other preprocess functions are getting called from the same template file. I have tried flushing the cache.

function bootstrap_preprocess_views_view(&$vars) {
  dsm($vars);
  dsm("aaaa");
  die;
}


texts: Insert Block Inbetween Paragraphs of the Content Body Field

texts:
I have a block I am trying to insert into the body field, catch is I want it to appear after the first two paragraphs. I tried using something similar to this in my node.tpl.php:

<?php
$array = explode ("
", $content['body']);
$array[2] = $myBlock . $array[2];
$content['body'] = implode("
", $array);
?>

//Important: This code snippet needs to be inserted before

<?php
print $content['body'];
?>

This code does insert my block in the body field, but also overwrites all the content in the field.

I'm using Drupal 7.10, any help is appreciated.


texts: How to remove paragraph tag from ckeditor?

texts:
When we insert content into ckeditor field,suppose we write single line of text into ckeditor without any html tag, why its wrapping paragraph  tag automatically around the text .

I need to remove this paragraph tag because its breaking my page's structure.


texts: Convert theme from ASP.net-based site to Drupal

texts: I'm supposed have to launch a Drupal 6 site within 4-6 weeks. Most of the content is already loaded into Drupal. But I'm having a dilemna about the fastest way to approach theming. Our university web developer is using Sitefinity (ASP.net) while I chose Drupal for our site. He gave me a copy of the unfinished template files a month ago (HTML, CSS, JS, images) which were designed using Blueprint CSS. I have just received  access to the main university site including admin priviledges. Since it is apparent that a lot of the final design was created using a skinning feature in Sitefinity, I downloaded the complete site using WinHTTrack and am trying to cobble together my "interpretation" of the design using the main CSS file done with Blueprint, and the Sitefinity system CSS files. The Sitefinity CSS files have their own layout which is based on percentages. I'm looking at creating either a Zen or Fusion based theme. I've tried removing all the Sitefinity styling and re-building the design from scratch using Blueprint in Dreamweaver.But I'm afraid this is a waste of time. I'd appreciate some advice on how others would approach replicating an ASP.net template for use in Drupal. While not at all familiar with Sitefinity, I did download a copy of all the files from the server in case they could be used to convert the layout to Drupal, although I know PHP and ASP.net themes are nothing like each other. Any strategies would be appreciated.


texts: What is the ID or class for the Wizard Page name?

texts:
In Webform 8 I am using the Attachment PDF / Entity Print to send a PDF of the submission via e-mail.

I am able to target the field labels, fieldset and webform-elements to add CSS but cannot find the correct ID or class for the wizard page titles.

Where do I find it?


texts: How do I get the blog teaser view display on a content type?

texts:
I know. I write English language really bad, horrible. I apologize.

I created a blog (with the core's blog module. Also I have a content type called my-content-type :). I need the blog teaser view is displayed in my my-content-type.

I installed Display Suite. So, my-content-type has the Display settings option. With this option I can choose the desired view, in my case the teaser view. OK, very good! Now, but how do I get the blog teaser view is displayed in my-content-type?

Can I do this without Views?

Greetings!


texts: Creating an editable table which can be updated

texts:
I have a site with about 150 users. I am going to implement a system whereby things that they do in the real world (it's a fitness company), such as attending sessions, introducing new customers etc will earn them points.

I would like to create a table with 3 columns:

Name | Points | Update

so something like this:

The idea being that my client (editor role) could log in and amend the points that each user has and then click update to modify each row. I guess the table would be equally useful if there were just a single 'update' button at the bottom of the table to update all entries at once.

I don't know how I might go about making a table such as this 'editable', but would really appreciate some pointers as to how you might accomplish this. I would stress that I'm okay with using contributed modules, but quite poor with creating modules and PHP in general!


texts:
I have this content type called "Product" that contains a "Multimedia asset" field (Media module), called Images.
Everything is working (I can access the image), except all my upload images have "null" in their path,e.g. "mydomain.com/sites/all/files/null/product-928.jpg."

The same happens when the image is rendered with a image style; in that case the path is "mydomain.com/sites/all/files/styles/table_icon/public/null/product-928.jpg."

("table_icon" is the name of my image style.)

I am using Drupal 7.10 and the Media module 7.x-1.0-rc2.

Do you have any idea on how to solve this problem?

Thanks!


texts: I need to hide the description field from regular users when entering data, but the field should be visible to administrator users, which also can edit it. I used the Display Suite module to hide that field by using different view modes, but I could not figure it out how to hide the field on forms. Any guidance would be appreciated!


texts: Drupal Views in Glossary mode removing pager

texts: I am adding alphabetical page to the view using glossary mode. I am able to create the alpha pager but the issue is, when I click on the alphabet the alpha pager doesn't appear again. I have to go back to view the alpha pager.


texts: Which hook can I use before or after submitting a webform form?

texts:
I created a webform form with drupal 8.

I would like to populate a database table with information from my form before or after submitting.

I guess there must be a hook like hook_webform_pressave () or hook_webform_insert () but I have not found the solution.

Thank you for your help


texts: How to use drush download file plugin (drush_dlf) project page has no information

texts:
How to use this plugin?

https://www.drupal.org/project/drush_dlf

  Drush Download File is a drush plugin that allows you to download files and place them in locations. This is behavior similar to what a make file can provide except you won't need to write a make file in order to get a file and put it in the right place.

This is what I am looking for, but there is not documentation, how can I do this?

I tried:

c:\source\sites\all\modules>drush drush_dlf
The drush command 'drush_dlf' could not be found.  Run `drush[error]

Not sure how to do this....


texts:
I am having an issue with the cache on my site's admin section.  I recently created a module that includes some admin pages.  I made a mistake with hook_menu, setting the wrong permissions for the settings at admin/zipcodes.  I got an access denied error.  I subsequently fixed the error but still get access denied.  I've reset the site cache, but it appears that the admin section is still using some cache somewhere.  I've had a similar issues in the past and am wondering if there's a way to get Drupal to purge the cache in the admin section.

Below is the page definition I created in hook_menu that is giving me an access denied error. As far as I can see it's working fine, and I'm guessing in the morning it will work as well.  It's just a little frustrating to have to now wait several hours before I can continue.

$items['admin/zipcodes'] = array(
  'title' => 'Statistics',
  'description' => 'List statistcs.',
  'page callback' => 'zipcodes_stats_page',
  'access callback' => 'user access',
  'access arguments' => array('administer content'),
  'type' => MENU_NORMAL_ITEM,
  'menu' => 'menu-administrative-menu',
  'file' => 'zipcodes.admin.inc',
);


texts: Can I enable both the Internal dynamic page cache and page cache modules?

texts: Is it suggested that enabling both the caching modules in drupal 8, will not cause any issue?


texts:
I have created an update that adds a fields to an existing database table. I would like to add that field to the list of primary keys already defined. How do I do this? Do I need to execute the following code?

db_drop_primary_key('table_name');
db_change_field('table_name', 'field_name', 'field_name',
array('type' => 'int', 'not null' => TRUE, 'unsigned' => TRUE),
array('primary key' => array(...list of field names...)));

I essentially recreate either an existing field or the new one I just added. Is there a simpler method where I can just add the field name to primary key list?


texts: How to unit test hook_form_alter implementation code in custom module?


texts:
example.com:8080/browse?category=137 is my URL for a taxonomy category page.

How am I supposed to take the category ID (137) from that URI?


texts: Is it possible to use random submission number for webform?

texts: In order not to let users know how many webforms are submitted, can the $sid config to increase by a random range?


texts: How to get the language code when a language name is given?

texts:
We are creating nodes programmatically on submitting a form. The language of a node is an input value in the form.
How can I get the langcode, when I have the Language name?

For example, user may type English. So i should convert it to "en"

If there an in-built function for that?


texts:
When i use drupal 6, i install control panel module and change panels  and authenticated users can goes to control_panel page and manage contents,pages and site.
but this module is not available for drupal 7.

my question is  how do you create a management page for your site in drupal 7 ?

Do you use another module or  add some php code to page and create this page manually?


texts:
http://www.ascoworld.com/services

On the above page, there is a block with three icons that links to the wrong pages. I want to change where they link to but can't seem to find out how. Apologies, but I am as new as can be at this. I didn't create the website and have never used Drupal before, I just got passed it and told to fix these issues.

Thanks!


texts: How to place multiple form elements from a loop

texts:
I have a table that will have multiple table rows that are generated dynamically using a foreach loop. In these rows will be textfields using the Drupal forms API.

Example:

$f = '
';
$f .= '
Something...
';

foreach($somethingAwesome as $val){
    $f .= '
';

    $form['blah'][$val] = array(
        '#type' => 'textfield',
    );

    $f .= '
';
}

$f .= '
Something else...
';
$f .= '
';

$form['woot'] = array(
    '#type' => 'whatever',
    '#prefix' => $f
);

This winds up outputting the form elements after the table in the page. This is not what I am expecting.

The output looks something like:

Something...
Something else...

Textfield
Textfield
(etc...)

It should look like this:

Something...

Textfield
Textfield
(etc...)

Something else...

I have tried using the #prefix in the textfield form elements but that produces some odd unexpected (at least for me) behavior.

I am using Drupal 7, if that makes any difference.

Edit: Added that I am in fact adding the $val to the $form element in the foreach loop


texts:
My module provides a simple block which needs to contain an unordered list with some images.
From a block function, I am returning a renderable array:

$block['content'] = array(
    'list' => array(
        '#theme' => 'item_list',
        '#type' => 'ul',
        '#attributes' => array('class' => 'foo1'),
        '#items' => array(
          /* ...  what should go here? */
        ),
    ),
);

I would like to have some renderable arrays as items in the item list, but I seem to be unable to insert any arrays into the #items array.

The Drupal 7 theme_item_list API docs says:

  items: An array of items to be displayed in the list. If an item is a
  string, then it is used as is. If an item is an array, then the "data"
  element of the array is used as the contents of the list item. If an
  item is an array with a "children" element, those children are
  displayed in a nested list. All other elements are treated as
  attributes of the list item element.

I tried using both "data" and "children" elements, but I get either empty <li>'s or there is a word Array inside them.

What is the proper way to do this? Is theme_item_list the right/up-to-date solution?


texts: How to create a product class programmatically in D7 / Ubercart 3

texts:
I'm looking to create a new module that when enabled will create a new content type and create an ubercart product class for it automatically.

I've tried googling and searching stackexchange for a few days but couldn't find much that is current or applicable to D7/U3 (or so I think).

There's plenty of info on creating a node programmatically.

My question is: Once I have created the node, how do I programmatically "productize it"?


texts: How to change the date of rewarded User Points?

texts:
When users publish a node on my website, they are rewarded some User Points with Rules. So when one publishes a new node on 25th June 2016, the User Points are stored with the exact same date.

As an administrator, I published some nodes where I changed the author and the date (say, 25th June 2012) in Authoring information in the node's form. However, after publishing, the User Points were of course stored as granted on 25th June 2016 instead of 25th June 2012.

Is it possible to change the date of a User Points transaction and replace it with the same time on which the linked entity (i.e. the node) was created? That is, in this case, the date of the transaction should be 25th June 2012.

I am aware that one can manually change the data in the database, but I suppose (and hope!) that there is a more efficient way.


texts: How to redirect toward a specific node from front-page

texts:
I have a multi language country site made in Drupal 6. And I want to check if I am on the front page then if true to redirect the user to a to some specific url. Drupal id doing it for country and language by default. But i want redirection for the default case also.

For example default option is global english site. So when a user takes www.example.com/ then it should redirect to www.exmple.com/global

Is there any way to do this?


texts: How can I include radiobuttons to a view's results?

texts:
I want to include two radio buttons to EVERY view's results, so a user can select one of them. This is actually a view with users results. Next to each result the following radio buttons will appear: "Active", "Suspend this member" and "Delete this member". How can I make these radio buttons appear on each view result?
Thanks


texts:
We are looking to allow logins in our university Drupal instance via OpenID for non-university account holders. We currently use the CAS module to authenticate university account holders.

We want to use OpenID instead of Drupal core accounts because we don't want to store passwords, passwords are sent in the clear, no HTTPS, etc. We'd like to offload authentication to services like Facebook, Google and Twitter by using OpenID and the OpenID Selector module. The problem is, with the Drupal account creation setting set to "Administrators only", OpenID throws the error "Only site administrators can create new user accounts." when you try to log in with OpenID. The CAS module works correctly to set up new users accounts with this same setting.

I need a way to bypass this setting when authenticating via OpenID. Is there a module that handles this, or can someone point me in the right direction? Thanks in advance.


texts: Customise Title Mark Up from template.php

texts:
On my site, I have several content types. They all use the same node--content_type.tpl.php file. However, the mark up applied to the node title has to change depending on the content type.

How can I modifying the title according to the content type from template.php?

(I don't want to use too many IF statements in my node.tpl.php file as you are supposed to keep those files clean, so I want the code to go in my template.php file).

(This question is for Drupal 7).


texts: How do I dynamically fill a textfield with #ajax?

texts:
As the title states, I'm wondering how I dynamically fill a textfield using an AJAX callback from a "select" form field.

I'm trying to test a select form with a number of options that, when changed, populates the textfield with data. I've tried setting the textfield's "#default_value", but it doesn't seem to work. Setting "#value" does work and I do get the information to show up in the textfield but this presents another problem. When I try to go to the next step and have a button save the data, the textfield's value remains what I set it to and doesn't change. What I mean is that when I select an option in the select form, the textfield gets populated correctly but if I change the textfield and hit save, the $form_state value is still what I set it to not what I changed it to. Is what I'm trying to do even possible?

$form['profiles'] = array(
    '#type' => 'select',
    '#title' => 'Profiles',
    '#options' => $profiles,
    '#ajax' => array(
        'callback' => 'profile_callback',
        'wrapper' => 'profile-wrapper'
    )
);

$profile = isset($form_state['values']['profiles']) ?
             _get_profile_info($form_state['values']['profiles']) : NULL;

$form['profile_name'] = array(
    '#type' => 'textfield',
    '#prefix' => '
',
    '#suffix' => '
',
    '#title' => 'Profile Name',
    '#value' => $profile == NULL ? '' : $profile[0]->{'name'}
);

$form['profile_save'] = array(
    '#type' => 'submit',
    '#value' => t('Save Profile'),
    '#submit' => array(
        'save_profile'
    )
);

I'm saving the value of my textfield from the $form_state into a file for testing right now.

function save_profile($form, &$form_state){
    $fh = fopen('C:\out.txt', 'w+');
    fwrite($fh, $form_state['values']['profile_name']);
}

function profile_callback($form, &$form_state){
    return $form['profile_name'];
}


texts: How do I define a route and controller for the home page?

texts:
A custom module called TSA contains almost all of the functionality for the /tsa subsite on my Drupal 8 multisite.

I want to define a route for http://localhost/tsa/, so that I can serve up dynamic content on the homepage depending on who the authenticated user is.

Here's tsa.routing.yml:

tsa.homepage:
  path: '/'
  defaults:
    _title: 'TSA Home'
    _controller: '\Drupal\tsa\Controller\HomepageController::content'
  requirements:
    _permission: 'access content'

And here's src/Controller/HomepageController.php:

<?php

namespace Drupal\tsa\Controller;
use Drupal\Core\Controller\ControllerBase;

class HomepageController extends ControllerBase {
  public function content() {
    return [
      '#type' => 'markup',
      '#markup' => 'Hello World from the HomepageController',
    ];
  }
}

But when I navigate to http://localhost/tsa, I just get Page Not Found.

Why doesn't it work? How should I go about doing this?


texts: Why does this very basic redirect module not work 100% of the time? Caching or something?

texts:
global $user;
  // Check if logged in
  if ($user->uid)  {
        if (arg(0) == null && !in_array('administrator', array_values($user->roles)) && !in_array('h5p', array_values($user->roles))){
    //redirect user to group page if they are loggged in
    $user = user_load($user->uid);
    $argument = $user->field_group_id_for_rules['und'][0]['value'];
      drupal_goto('node/' . $argument);
    }
}

I just want users to get redirected to the NID saved in their profiles.. It works 98% of the time but really ruins the user experience when it doesn't.

Also, is it a bad approach or inefficient?

Edit: The fixed code with drupal_is_front_page() which didn't work before without hook_init().

<?php
function custom_hp_redirect_init() {
global $user;
  if ($user->uid)  {
        if (drupal_is_front_page() && !in_array('administrator', array_values($user->roles)) && !in_array('h5p', array_values($user->roles))){
    //redirect user to activity page if they are loggged in
    $user = user_load($user->uid);
    $argument = $user->field_group_id_for_rules['und'][0]['value'];
      drupal_goto('node/' . $argument);
    }
  }
}


texts: How to add my own images to the views slide show?

texts:
I am new to Drupal. I have been trying to make a slide show on the front page but I am facing an issue on how to upload images of my choice in the slide show. I.e. the images that I have in my computers folder.

I have created a view and placed an image field in it, everything is set. I have also added the block to the main page content. All I can see on the front page is the slider title obviously since i have not been able to add any images.

Can any body tell me how to set my own images to the slider?

I don't want to use fixer slider.

I have used views slide show and some other js files for cycle.

Edit: Here is a screenprint of the view I defiined so far:


texts: Database corrupted getting the site crash

texts:
I crashed my website trying to secure it by changing files and folders modifications...After i tried many things (chmod 777 -temporarly- all to take it back, clear the cache, drush rr...) nothing worked yet. So i tried to install a new site, copied all the site file...It was working perfectly.

I tried to link the new site with my old database, and the fatal error get back again...I guess my database might be corrupted...Any idea ?

Thanks for your help

(previous conversation about what i did already here


texts: How to render a static html from a drupal module

texts:
I need to call a static html page and display the content of it when calling it from the module function , i tried to call from the form api but its just rendering the full markup ,please help

here is the try :

$items['mailusers/staticpage'] = array(
    'title' => t('My Static Page'),
    'page callback' => 'my_static_page',
    'access arguments' => array('access GASF admin menus'),
    'access callback' => TRUE,
  );

  return $items;

and the function

function my_static_page() {
     $form['html'] =  array(
    '#type' => 'markup',
    '#markup' => //'
My Heading
'
         file_get_contents(drupal_get_path('module', 'mailusers') .'/mailuser.tpl.php'),
  );
 return drupal_render($form);
}


texts: How to change a field value in a product variation when someone edited the order manually?

texts:
I had implemented a "Event Subscriber" controller to change the stock value in the product variation. Stock is a field in product variation.

Depending upon the quantity in order items I am decreasing the value of stock by subscribing to Drupal 8 event order $events['commerce_order.place.post_transition']. Similarly I increased stock value if he cancels the order using the event $events['commerce_order.cancel.post_transition'].

If somebody revise the order quantity from Back-office that time, stock should be increased or decreased accordingly. How can we achieve that? Is there any event when order items is edited?  we are currently decreasing stock when order is placed... how can we decrease/increase when somebody edit the order from backend manually?


texts: How can I pass a variable to javascript from a preprocess function?

texts: How do I pass $variables['is_front'] from template_preprocess_page() to a jquery script in Drupal8?


texts: Allow authenticated users to update submissions

texts:
Drupal 8.6.5 and Webform 5 here

I have a webform in which I have enabled Signature Pad (I mean https://github.com/szimek/signature_pad). I would like to implement a workflow such that:

An authenticated user submits the form, and an email is sent to another authenticated user with a link to the webform submission (this second user is chosen by the first user by filling a field in the form)
The second user is able to follow the link, authenticate and update the first user's submission (he adds his signature to the submission)

This is easy to accomplish when the second user is known (just a matter of access permissions), but how can I implement such a thing when he is not known/predetermined?


texts: How do you properly render the body when pulling it from the database using db_select?

texts: I have a db_select() that returns the *body_value* and *body_format* from the table field_data_body...how to I properly render that in Drupal?


texts: Migrate existing content types to MongoDB

texts:
I have a "Company" content type that has about 30 fields that I'd like to migrate over to MongoDB (field_sql_storage to mongodb_field_storage).

Would anyone know of a great way to do this?

I have about 150,000 nodes and it's starting to get slow in MySQL.

Thanks!


texts: remove description in views exposed filter

texts:
Is it possible to remove the description of views exposed filter widgets in other way as css display:none?

I tried to unset $widget->description, but without any success.


texts: Print user uploaded logo in twig template

texts:
How can I print a user uploaded logo (via the theme appearance UI) in a twig template?

For example, in block--system-branding-block.html.twig we can use

Available variables:
- site_logo: Logo for site as defined in Appearance or theme settings.

  <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" />

What do I need to do to make that variable (or a custom variable) available to another twig template, like menu.html.twig?

I have found many solutions, but all them involved hardcoding the logo file name or location, both of which are obviously not user friendly.


texts: User registration with e-mail + password

texts:
I am trying to set up a user registration form allowing to register with only an e-mail and a password, in Drupal 8.

I struggled a little and decided to use the e-mail registration module for Drupal.

The thing is, it only allows for an e-mail field and all other fields are removed, including the password.

How can I add a working, validated password field to a User upon registration?

Is this good practice by the way?


texts: How to get the value of a variable in CCK from Devel?

texts:
I am using a custom .tpl file to theme teasers, and I am having trouble with the value of a variable returning true even when apparently there is no value inside ($picture). I would like to see what exactly this variable contains.

How do I leverage Devel to view this variable without having to var_dump()? Currently, the teasers are inside a view which is inside a block on the home page.


texts: How to create a 3rd Ad push in a custom Omega Kickstart subtheme

texts:
I'm using drupal commerce kickstart 7x to design an experimental website to understand the layout & methods of the CMS.

I've just started using Drupal. To be precise, 3 days. This is very new to me.

I want to know how does one go about placing a 3rd Ad Push block in the "Postscript third" section. I've sub themed Omega kickstart.

I've tried creating blocks, editing the fields, editing views, reordering the blocks and contents. Yet none seem to work.

I can only create a block with text as its body. But what I want to achieve is a 3rd block with an image in it just like the preceding 2 AD Push blocks.

How do I do it?

Images for reference:


texts: Create users on the frontend, without 'administer users' permission

texts:
As you may know, there's one single permission that controls user's access to other user's creation - permission is called 'administer users'. It either gives access to full user's administration or to nothing.

On my system I have tiered users who are supposed to have some permissions in relation to user administration. But not all permissions. I basically need to be able to create user accounts (based on profile2) on the frontend url (not /admin/people/p2rp-create/user but eg. /add-user.

I know there's a way of rendering an existing Drupal registration form, not sure how to
a) render profile2 form, or, to be precise, render profile2 form that includes forms for few created profile (I have 3 at the moment)
b) make it create a user even tho user doesn't have 'administer user'

I played with the following for starters

function module_menu(){
  $items['add-user'] = array(
  'title' => 'Add user',
  'page callback' => 'module_reg_form',
  'access arguments' => array('access create customer'),
 );

function module_reg_form(){
  $user_register_form = drupal_get_form('user_register_form');
  $form_state = array('profiles' => array('contact_details'));
  $registration_with_profile_fields_form = profile2_attach_form($user_register_form, $form_state);
  print(drupal_render($user_register_form));
}

This throws an error

EntityMalformedException: Missing bundle property on entity of type profile2. in entity_extract_ids() (line 7721 of /home/dreamweddings/www/dreamweddings.eu/public/includes/common.inc).


texts: Disabling auto-removal of 'rel' attributes in full HTML input format

texts: My Drupal 7 site , which is using Wysiwyg with the TinyMCE library, keeps removing the 'rel' attributes. Do you have any idea on how I disable this?


texts: Drupal taxonomy break after using mytheme_preprocess_node function

texts:
I'm trying to make custom drupal 7 template. I want print breadcrumb on the top of every node page. I'm using Breadcrumb and menu Breadcrumb module. I had trouble put my breadcrumb on page so I decided to create new region, then put breadcrumb block inside it, and render it on my page. Because regions are not available by default in node template, I used function like that:

function mytheme_preprocess_node(&$variables) {

  // Get a list of all the regions for this theme
  foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {

    // Get the content for each region and add it to the $region variable
    if ($blocks = block_get_blocks_by_region($region_key)) {
      $variables['region'][$region_key] = $blocks;
    }
    else {
      $variables['region'][$region_key] = array();
    }
  }
}

It's work nice, but after add that taxonomy module just behave weird. It stopped working on other pages than main page. Any idea what may cause that?


texts:
On node add/edit form, when the navigation menu grows, it becomes harder to find the menu parent in which we want to add the node link. Is there any module through which it becomes little easier?

Secondly, on the menu management page where it displays all the menu items, is it possible to drag multiple menu items? Is there any menu management module like the Taxonomy manager module?


texts:
A classified like site requires very different fields per category or taxonomy term.  For example car will need fields like milage, model etc.. while a house will have no. of bedrooms, sqr. feet etc. I am finding different ways to do this but not sure which is scalable.  I will also be using faceted search api.

First Method:
Create a generic entity with common fields and programmatically create custom entity per category which will be related using entity reference.

Second Method:
Create single entity or content type with all fields and write logic to hide and show fields per category.

Third Method
Create content type per category.


texts: Hook_form_alter for changing field labels doesn't work of user registration page

texts:
Can anyone tell me why this isn't working (in the below code, or other factors preventing the insert by the hook)?   I don't get an error message or page, the field labels are simply not overwritten...

I created my own module with the following hook on Drupal 8.5.7:

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

  if ($form_id == 'user_register_form') {

    $form['field_user_first_name']['widget']['0']['#title'] = 'First Name';
    $form['field_user_last_name']['widget']['0']['#title'] = 'Last Name';
    $form['field_user_phone_number']['widget']['0']['#title'] = 'Phone Number';
    $form['field_user_country_of_residence']['widget']['0']['#title'] = 'Country (of residence)';
  }
}


texts: How do I add role permissions to custom module

texts:
I have a custom module in Drupal 8 and I have created a role called editor.
How do use .permissions.yml in my module to get it to display on the editor's role?


texts: How to reorder nodes in Drupal 7 using Drag and Drop feature?

texts: Can anyone please help me that, how I can reorder the nodes in Drupal 7 using drag and drop feature?


texts: What is better for performance: Many entity types with one bundle or one entity type with many bundles

texts:
I am using the ECK module to build custom entities.
When using custom entities, the decision must always be made: shall I create a number of entity types or shall I create one entity type with a number of bundles.

From a usability perspective, the latter is obvious since, just as the node system, all entity types can easily be connected in views. It gets harder when different entity types must be used in views.

Apart from that, I assume that there must be a benefit from using multiple entity types. It has something to do with memory that drupal carries around, but it is not clear to me what exactly makes a difference.

I am aware of the benefit of using entity properties instead of fields. However, most of my entities use fields that cannot be replaced by a property.

So the question is: should I in general aim for using more entity types (each of which automatically create one bundle) or should I not worry about performance impact and create all bundles under one (generic) entity type.


texts: Add more fieldset with remove option custom module

texts:
I'm developing custom module and there's one fieldset that can be added multiple times and can be removed any particular entry also. Can anyone please suggest to achieve this? Here is my code:

function hook_form($form,&$form_state){
$form_state['storage']['emails'] =
isset($form_state['storage']['emails']) ? $form_state['storage']['emails'] : 0;

$form['emails'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
    '#prefix' => '
',
    '#suffix' => '
',

);
if(empty($form_state['storage']['emails'])) {
    $form_state['storage']['emails'] = 0;
}
for ($j = 0; $j <= $form_state['storage']['emails']; $j++) {
    $form['emails'][$j]['candidate_email'] = array(
        '#title' => 'Email',
        '#type' => 'textfield',
        '#size' => '30',
        '#required' => FALSE,
    );
}
$form['emails']['add_email'] = array(
    '#type' => 'button',
    '#value' => t('Add Email'),
    '#href' => '',
    '#ajax' => array(
        'callback' => 'hook_ajax_add_emails',
        'wrapper' => 'emails',
    ),
);
$form_state['storage']['emails']++;

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

function hook_ajax_add_emails($form, $form_state) {
    return $form['emails'];
}


texts:
I am hosting an Acquia Drupal site on AWS:

I currently have 2 sites both located in the sites folder:

I am fairly new to working with Drupal Multi-sites and would like to know what is the best way to point to each folder's settings.php with this format and ignore the sites/default folder?

And if it would be simpler in another format what would you recommend?

Let me know if you have any questions.

Thanks!


texts: Rule to create user on webform submission by anonymous user

texts:
I'm trying to create a user with rules on webform submission by anonymous user, as the title says. I set my event (After a webform has been submitted), set my conditions and set my actions. Create a new entity of user whose name will be [data:name-value] and e-mail address [data:email-value] as seen below . But I get Unable to evaluate action entity_create. However, I know [data:name-value] works it prints when I show it on the screen. User creation also works because a user is created when I enter fixed values. What could I be missing?

PS: I could roll my own module for this small task, but why bother when I can do it with rules?


texts: What is the simplest way to flush cache at a predetermined date and time?

texts:
For site a) I would like to set up a schedule "page and else"cache clear every day at midnight.
For site b) I would like to set up a schedule full cache clear every Wednesday day at midnight.

I am using the modules Varnish and Expire (Cache Expiration) to clear node caches when events occur (added deleted node etc).

As far as I can tell Rules does not provide Time/Date as an event which can be used as a trigger.

I am looking to do this internally in Drupal rather than on the servers cron.
Is there a simple way to achieve this?


texts: how to create rules to send email notification for node reference content?

texts:
I have two content types: job posting and job application.
The job application content type has a node reference field for job posting. Whenever  users create a job posting node, other users can send a job application to that job posting by filling the fields.

How can I send a notification to the user who had posted the job application node when the node has been created?


texts:
I have a decoupled Drupal website and I want to call a REST resource outputing CSV, using the CSV Serialization module. I have also configured REST UI to accept CSV in that particular resource.

I tried sending headers with Content-Type: application/csv, or Content-Type: text/csv, I'm sending _format=csv as a GET parameter, but the only response I'm getting is:

   "No route found that matches ""Content-Type: application/csv"""

What am I doing wrong?


texts: Updating Drupal project using Composer fails

texts:
I have site (which is originally installed also with composer) with drupal core version 8.7.2. I'm trying to update it to latest 8.7.8. When I do:

composer outdated "drupal/*"

I get the list of all outdate and for core I get row:

drupal/core                       8.7.2       8.7.8       Drupal is an open source content management platform powering millions of websites ..

But when I try:

composer update drupal/core --with-dependencies

I get:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files

In composer.json core is added under require as (I just followed install docs - didn't change anything by hand):

"drupal/core": "^8.7.0",

That was suspicious to me so I tried replacing it with:

"drupal/core": "8.*",

But result was the same - nothing to update.

That message about phpunit/phpunit-mock-objects dependency is in green so I doubt that it causes this update to fail, but I'm not sure.

Why composer says that there's nothing to update?

Update:

Tried also:

composer prohibits drupal/core:8.7.8

and it says:

webflo/drupal-core-require-dev  8.7.2  requires  drupal/core (8.7.2)

And I really have inside composer.json:

"require-dev": {
    "webflo/drupal-core-require-dev": "^8.7.0"
},

Also tried:

composer update drupal/core --with-dependencies --no-dev

which removed dev dependencies, but also didn't update drupal core.
How to solve this?


texts: validate field using regular expression in Field validation module

texts:
I have added a text field in a content type. I'm looking to validate that field by adding a Rule using "Field Validation" module. I found few options in this module like regular expression (  Regular expression (Perl-Compatible) , Regular expression (POSIX multibyte) ). I have used this options but i'm not above to get the results. Actually i want to check a field value which matches character like numbers 0-9 and special character like ( , ) , - , + .

If the field value contains any other values, then i have to display an error message like "Invalid Input" .

I have tried using the following regular expression.

[0-9+()-]+

SCREENSHOT :

when i check this expression in this website (http://www.regexr.com/). Its working fine.

Any help would be greatly appreciated.


texts: Drush fails on D8 sites but works on D7 sites - PHP Version Issue?

texts:
We have a CentOS Linux 7 server with Plesk running several Drupal 7 and a few Drupal 8 sites.

Drush commands work fine on all D7 sites, but on all D8 sites any Drush command returns:

  PHP Parse error:  syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /var/www/path/to/drupal8site/httpdocs/vendor/symfony/var-dumper/Resources/functions/dump.php on line 18

Running drush status on any D7 site returns a standard report:

 Drupal version                  :  7.65
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database username               :  dbusername
 Database name                   :  dbname
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  themename
 Administration theme            :  seven
 PHP executable                  :  /opt/plesk/php/7.1/bin/php
 PHP configuration               :  /opt/plesk/php/7.1/etc/php.ini
 PHP OS                          :  Linux
 Drush script                    :  /root/.config/composer/vendor/drush/drush/drush.php
 Drush version                   :  8.1.17
 Drush temp directory            :  /tmp
 Drush configuration             :
 Drush alias files               :  /var/www/path/to/drupal7site/httpdocs/sites/default/example.aliases.drushrc.php
 Install profile                 :  minimal
 Drupal root                     :  /var/www/vhosts/pinnbank.chronosdv.com/httpdocs
 Drupal Settings File            :  sites/default/settings.php
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp

Running drush status on a D8 site returns the PHP Parse error described above.
 My research has indicated that there is a disagreement about which PHP version Drush should be using.
I have tried multiple variations of export DRUSH_PHP=/opt/plesk/php/7.1/bin/php but nothing I do seems to make any headway.

Does anyone have any ideas about what to try next?


texts:
In a content type there are tabs at the bottom for publishing options, add menu item, url alias, comments, etc. You can set defaults/access to these options when you create the content type. But what if you want to give the superadmin access to these options but not a lower level admin? And do this on a per node basis?

For example, I don't want the lower level admin to change the URL alias, publishing settings, or the menu position on a top section node, ie xyz.com/about. But he can make a revision.


texts: Search API Database Search score calculation

texts:
I'm trying to understand how the Search API Database Search calculates the score for a search result. I understand Solr uses the Lucene scoring model and there's also command that can be used to output the actual calculation (debugQuery=true).
Is there documentation and/or a debug command I could use to understand how the engine is coming up with the score for a result?


texts: How to add a CSS class to some certain pages depending on the path alias?

texts:
I'm trying to add a CSS class to some certain pages for some certain menu styling depending on the current alias path. It works well with the following function but I'm wondering is there another way to split the current alias parts so I can use them as arguments? Here's my present function:

function mytheme_preprocess_html(&$vars) {

  $path = drupal_get_path_alias($_GET['q']);
  $aliases = explode('/', $path);

  if (isset($aliases[2]) && $aliases[2] === 'foo') {
    $vars['classes_array'][] = 'bar';
  }
}


texts: Webform file upload field replacing existing file in directory in drupal

texts:
I have created Webform in Drupal in the following fields

Name   - Text field
Age    - Text field
Picture - File field

when uploading user file in the file field, the file name is photo.jpg again the another user uploading file in the file field the file name is called photo.jpg. The file location directory is replacing into photo_0.jpg but this value is not updating in the database.

while I am selecting this data from database the photo is changing i.e i am getting different file for different user. What should i do for this? please give me any solution.


texts:
I am having problems with the nice edit wysiwyg: The width seems to be set at 100px, and I am not sure how to go about changing this.

This is the HTML snippet:


texts: How to send an email 1 minute after a node is created or updated by using a scheduled Rules Component?

texts:
So far, I've used Rules to unpublish a node 2 minutes after it is created or updated (testing for now). Now, I'm trying to send an email reminder to the node author 1 minute after the node is created or updated. So far, this is what I've done:

Create rules component >> action set "send email":

Scheduled evaluation date: node:changed
add offset: 1 minute
User node reminder: node:source:author (i also tried node:author).

Create new rule "schedule email publishing":

Event: After saving new content
Condition 1: content is of type: advertisement
Condition 2: content is published
Action: Schedule component evaluation: Rules Component: send email.

What am I doing wrong?


texts: How can I switch menus after a user logs in

texts:
I'm trying to create a register/login links in the format "Register or Login" which is display for anonymous users and switched out with the user menu when a user is logged in.

I know I can preprocess those links as variables in template.php but am not sure how to access the user menu from template.php in order to write an if statement.

Ultimately, if I could do something like Forrst (images below), then tahts what I would love to end up with, but for now just trying to keep it sweet and simple.

From This:

To This after login:


texts: How to store field data in a file instead of the db?

texts:
So far, I found two decent options for storing field in a file:

using node hooks to store data in a filefield, and process it on node view
theoretically, the best would be to use file storage as a backend, but is there a module for field file storage instead of field sql storage?

My use case is a field that does not change, but mysql backup is very slow because there are 600 000 nodes with it. I also do not need to query this field, just display it. With file storage I can do incremental backup which is lightyears more efficient.


texts:
I am working on a multilingual site right now, and am using the Internationalization suite of modules to build it out.

The site has some custom blocks in it that I would normally use DRUPAL_CACHE_GLOBAL in the hook_block_info() definition.  However, some of these will have translatable strings in them, so I really need to cache them per-language.

Is this possible?  Or, is my only real option to use DRUPAL_CACHE_PER_PAGE?


texts: Job board: Faceted Search with "OR" operator, but sort results by most matching facet criterias/term count

texts:
I'm quite stuck with searching for a solution for my problem and I hope that you can maybe help me.

In general I want to build a small job platform. It includes an "Explore"-Section, which is just like a Search-Page with Facets.
The actual job-nodes can be tagged with terms of the two vocabulary "skills" and "interests".
The facets on the search page allow the user to filter jobs exactly along these skills and interests.
However, I want to use the "OR"-Operator for the Facets, so that the user gets a list with jobs, that nearly perfect match their skills & interest but also jobs that match only some of these terms.

So, here you can see the default listing page. On the left are the Facets for interest and type (Operator "OR"). On the right, you can see the result set with title, and the node's skills & interest terms:
Jobsearch Default page

Now, I'm applying "Musik" and "Kultur" as interest-filters:
Jobsearch with applied filters

As you can see in the result-set, the OR-operator delivers all the results.
However, I would like to sort these results according to their "relevance" resp. according to the count of matched criterias.
The 4. and 5. results match both terms, that are selected in the facet, but they should be listed in front of all other terms.

So, I hope you understand what I want to achieve. I started at first with Views to accomplish the goal, but I then switched to search_api and SOLR as I think, that this approach is more enhanceable in the future.

The second aim is, that a user can store his/her individual interests & skills (the filters mentioned before) in his user profile. Here, the user should see individual job recommendations based on his profile on his account-page.

So, any hints, tips, tricks, links are very welcome as I have no idea if I'm on the right track to solve my problem(s). :)

Robert


texts:
So I'm using a "file" type input inside a form which is called within a popup...but then whenever I submit that form inside the popup after having selected a file, the popup always return an error....

Is there a way to prevent this from happening and to successfully submit the form accordingly even with a file upload?


texts: Create comment with services 3.X on Android with JSON

texts:
I'm developing one Android app.

I'm trying to post a comment from the app to Drupal via Services module, but I can't send a JSON data to the module, there is the Java code:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.com/serviceapi/comment");

String datos = "{\"name\":\""+username+"\",\"uid\":"+uid+",\"nid\":"+nid+",\"comment_body\":{\"und\":[{\"value\":\""+comment+"\",\"format\": \"filtered_html\"}]}}";

//add raw json to be sent along with the HTTP POST request
StringEntity se = new StringEntity(datos);
se.setContentType("application/json");
httppost.setEntity(se);

httppost.setHeader("X-CSRF-Token", token);

BasicHttpContext mHttpContext = new BasicHttpContext();
CookieStore mCookieStore = new BasicCookieStore();

//create the session cookie
BasicClientCookie cookie = new BasicClientCookie(session_name, session_id);
cookie.setVersion(0);
cookie.setDomain("example.com");
cookie.setPath("/");
mCookieStore.addCookie(cookie);
cookie = new BasicClientCookie("has_js", "1");
mCookieStore.addCookie(cookie);
mHttpContext.setAttribute(ClientContext.COOKIE_STORE, mCookieStore);

//Send the request
HttpResponse response = httpclient.execute(httppost,mHttpContext);

//Get the drupal response data
Log.e("Estatus code", Integer.toString(response.getStatusLine().getStatusCode()));

BufferedReader rd = new BufferedReader(
    new InputStreamReader(response.getEntity().getContent()));

StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
  result.append(line);
}

Log.e("Data",result.toString());

But I get the following error:

E/Estatus code﹕ 500

E/Data﹕ ["A nid must be provided"]

I don't know what can I do, if I provide a nid, why services don't get the nid, I try in Firefox plugin Poster, and that JSON code works, with Poster I can add comments.


texts:
I want to redirect the users to a particular page when they view a certain page when there are some conditions. The condition is that the user has uploaded a node, for example an article.

Say there are two pages, Page A and Page B.

Page A Link <-- if the user has not uploaded a node, clicking on this link will take him to Page B

I have installed the node limit module which allows the user to upload only one content.


texts: How do I structure node data that records time and quantity?

texts:
I have a node that will have one field that will be updated often by adding a field with a time and quantity of an item. I would like to output the data as a table.

Some fields the node will have are:

Title
Description
Type
Year

Then it will have data that is updated attached to it:

Monday | 4
Tuesday | 7
Friday | 3
Sunday | 9
Monday | 3
Friday | 7
.
.
.

I need a field to contain both the data/time and the quantity. Do make a new entity to contain this information and have a mutli value entity reference field? Do I create a field collection? Do I instead make a two value field with the field API? What is the simplest way to store this data? The field will be updated programmatically.


texts: How to create a new entity with default values if not passed?

texts:
Hello everyone how are you?
I created a new configEntity called Modal with 3 fields:

Label
Body
Auto Open

To create a new Modal I'm using this code:
$modal = \Drupal::entityTypeManager()->getStorage('modal')->create();

$modal->setLabel('Modal Title');
$modal->setBody('Modal Content');
$modal->setAutoOpen(TRUE);
$modal->save();

OK! It works!
But now I don't want to pass "auto-open" and I this value with TRUE as default. Like this:
$modal = \Drupal::entityTypeManager()->getStorage('modal')->create();

$modal->setLabel('Modal Title');
$modal->setBody('Modal Content');
$modal->save();

Note that there is no "Auto-Open" and it inserts a new Modal with "auto-open" = FALSE
My goal is; if you don't pass "auto-open" this field is filled with TRUE by default.
Do you know how can we do this?
Thank you so much, everyone


texts: Call to undefined function t() in an Unit test

texts:
I'm trying to test a method from the dev version of the Allow a content type only once (Only One) module that have a t() call inside:

<?php

namespace Drupal\onlyone\Utility;

class InternalFunctions {

  public static function getLanguageLabel($language) {
    switch ($language) {
      case 'und':
      case '':
        // If the language is empty then is Undetermined.
        return t('Not specified');

      case 'zxx':
        return t('Not applicable');

      default:
        return ucfirst($language);
    }
  }

}

With the following Unit test:

<?php

namespace Drupal\Tests\onlyone\Unit;

use Drupal\onlyone\Utility\InternalFunctions;
use Drupal\Tests\UnitTestCase;

class InternalFunctionsTest extends UnitTestCase {

  public function testGetLanguageLabel($language_code, $expected) {
    $this->assertEquals($expected, InternalFunctions::getLanguageLabel($language_code));
  }

  public function providerGetLanguageLabel() {
    $tests[] = ['', 'Not specified'];
    $tests[] = ['und', 'Not specified'];
    $tests[] = ['zxx', 'Not applicable'];
    $tests[] = ['es', 'Es'];
    $tests[] = ['en', 'En'];

    return $tests;
  }
}

and when I run the test I receive these errors:

1) Drupal\Tests\onlyone\Unit\InternalFunctionsTest::testGetLanguageLabel with data set #0 ('', 'Not specified')
Error: Call to undefined function Drupal\onlyone\Utility\t()

/Users/adriancid/Sites/drupal84-test/modules/drupal.org/onlyone/src/Utility/InternalFunctions.php:26
/Users/adriancid/Sites/drupal84-test/modules/drupal.org/onlyone/tests/src/Unit/InternalFunctionsTest.php:30

2) Drupal\Tests\onlyone\Unit\InternalFunctionsTest::testGetLanguageLabel with data set #1 ('und', 'Not specified')
Error: Call to undefined function Drupal\onlyone\Utility\t()

/Users/adriancid/Sites/drupal84-test/modules/drupal.org/onlyone/src/Utility/InternalFunctions.php:26
/Users/adriancid/Sites/drupal84-test/modules/drupal.org/onlyone/tests/src/Unit/InternalFunctionsTest.php:30

3) Drupal\Tests\onlyone\Unit\InternalFunctionsTest::testGetLanguageLabel with data set #2 ('zxx', 'Not applicable')
Error: Call to undefined function Drupal\onlyone\Utility\t()

But the t() function is always defined inside Drupal. If I remove the t() calls inside the method the test works fine.

I found in Unit testing more complicated Drupal classes that:

  ... global functions do not exist in the testing environment.

And a method to made this works, but I find that this is complicate things just to use a test and method with the t() function inside.

So, there is not a simple method to test a class method that have a t() call inside?


texts: why not redirect to another page after form submit

texts:
I do this in my form submit

    $form_state['redirect']='checkout/' . $order->order_id;

but it not redirect to checkout page ( I test with another urls but it not work),
I take screen shot after set redirect ,

also I get $from_state by ref in function function pre_register_node_form_submit($form, &$form_state) {  , what do you think? where is the problem?

another note is when I am use drupal_goto form not saved !!!, it redirect to my page with out anything saved.

Do you suggest me declare another submit function and add it to submit array of my content type and in it set redirect?

Update

also I test below

 if ($form_id == "pre_register_node_form") {
       $form['#submit'][] = 'mysite_submit_redirect';
}

function mysite_submit_redirect(&$form, &$form_state) {
  $form_state['redirect'] = 'home';
   // ym($form_state);

}

but not redirected :(


texts: data selector not working in custom Module

texts:
I am working in a module and I have added custom date data attribute to ubercart order.

Now, I would like to create a data selector in rules for custom date attribute of the order.

I have implemented hook_rules_data_info() into my custom module but its not showing in data selector in rules.

/**
 * Implements hook_rules_data_info().
 */
function uc_datepicker_rules_data_info() {

  $entities['uc_datepicker'] = array(
    'label' => t('Ubercart Delivery Date'),
    'group' => t('Ubercart'),
    'wrap' => TRUE,
    'token type' => FALSE,
  );

  return $entities;
}

I have also added implemented hook_rules_condition_info() hook and its showing date condition into rules correctly.

Please suggest, how can I add data selector in rules for date attribute of the order in my custom module.

Thanks,


texts:
I have this code:

function mymod_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['account']['#weight'] = 100;
}

Which is supposed to push the 'account' section of stuff underneath the rest of the form elements. But the weight seems to be fixed/the order is unchanged?

I've inspected the $form array at the point my code runs, and there are all the other fields, with their respective #weight values; and 100 is larger than any of those.


texts: Why can't I edit "Settings" on rules components in the Rules UI?

texts:
When I click to edit a rule in the Rules UI, "Settings" is displayed in blue and upon clicking "Settings" the "Name", "Tags", "Active" and "Weight" options are presented.

However, when I click to edit a rules component, "Settings" is displayed in black and I cannot edit the name of the rule nor the arguments.

Before, I solved this problem by:

clearing the Drupal cache (twice)
clearing the cache in my browser and restarting it
switching to a different browser (e.g., from Firefox to Safari)

However, this time none of the above worked.  How can I edit the settings for rules components?