texts: Can a database query be written inside a template.php file?

texts:
I am writing a query inside the following function of template.php file

        function theme_name_process_views_view_field(&$vars) {
 if ($vars['view']->name == 'view_name') {
// query is written here
      foreach( $vars['view']->result as $key => $value ) {
          $nid = $value->nid;
          $query = db_select('abc_in', 'abc')
            ->fields('abc', array('study_abc'))
            ->condition('abc_nid', $nid , '=');
          $result =   $query->execute()->fetchField();
        $vars['view']->result[$key]->field_field_abc_in[0]['rendered']['#markup'] = "
" .  $result . "
" ;

    } }

Is it ok to write a db_query inside template.php file ?
I an taking a data from custom table and inserting value into field of a view ?


texts:
Have a Superfish menu on a purchased Drupal 7 theme. sub-links off the main menu currently drop down vertically. I cannot figure out how to enable/configure the Superfish MegaMenu so the sub-links can be displayed horizontally as follows:

ITEM1
 - subitem     - subitem     - subitem
 - subitem     - subitem     - subitem
 - subitem     - subitem     - subitem
 - subitem     - subitem     - subitem


texts: Views: Ranking users by pageviews this month, last month

texts:
I have created a view to rank Users by the total numbers of pageviews their nodes have received. I now want to clone that view and create 2 blocks:

Totals views their nodes have received this month
Total view their nodes received last month.

I have tried using contextual filters and I can create a view to show total pageviews in a date range, but, that would mean me updating the filter every month. Is there another way I can do this? I don't want to limit the results to "last 30 days". Rather, January, December etc

Thanks!


texts: Avoid hard crash if user searches when Solr stopped

texts:
I use search_api_solr with a server-based Solr installation. Works fine. For reasons I won't explain, the Solr service is stopped sometimes. If a user does a search while Solr is stopped, they crash with "The website encountered an unexpected error."

The error log  says "Drupal\search_api_solr\SearchApiSolrException: An error occurred while trying to search with Solr: Solr endpoint http://localhost:8983/ unreachable or returned unexpected response code "0"." No surprise, since the service is stopped.

How can I trap this error and display a "Search isn't working" page instead of crashing? Seems like there should be a way to intercept it, but I haven't figured it out.


texts: Is there an easy way to prepopulate webform field default values from profile2 field values?

texts:
We are working on major project where client wants webform fields to be prepopulated from profile2 fields. Webform version 3.17

Is there any way to create tokens or similar from profile2 fields to be used on webform default values?


texts: I am using the module Print for print/mail node's content. However, I have problems to send email. I want to hack the module, so it will use the PHP class PHPMailer instead, and will hard-code the sending of the email. Everythings works perfect, but the situation is that there is no API and I have hard-coded directly in the module, so when the module is upgraded, I will lost my coding. Is there any way of making a hook of the desired function so I will get the same working but will still be able to upgrade the module without problems? I will accept other solutions, but the question is more general (I maybe would need to do something similar with other modules which do not provide API in the future). Thanks!!!


texts: How much PHP do I need to know in order to create new modules?

texts: I don't really have much php knowledge but would like to be able to create custom modules. Will this be possible? Or have I got no chance?


texts:
Ubunutu Server, two Drupal sites. One dev and one live. Both domain names take you to the same code and database, the ones correct for the live site.
Checked apache virtual host files. Both the dev and live sites are pointing to different directories where they should go, one to the live code, and one to dev.

What setting, and where, could make the dev site point to the live one, instead of where apache's virtual host file says it's pointing?

*I should add, this occurred after a server upgrade.


texts: When enabling Clean URLs, test passes, but ticking & updating fails

texts:
I have mod rewrite running fine and the test passed ont he CLean URLs page, however when I tick the box to 'Enable clean URLs' and click 'Save configuration', I get a message saying 'The configuration options have been saved.' however the box remains unticked and I get the same page below!

Any ideas why it is not enabling here?


texts: How can $build['#attached']['drupalSettings'] change from hook_node_view to javascript?

texts: I'm afraid the title isn't clear: I am passing a value from hook_node_view to my javascript in $build['#attached']['drupalSettings'][]. But the value that is set there is not the value that the js is using. I've checked in several places to make sure that this value is indeed the one set in the variable; nevertheless, the js script is getting a different value. I'm sure I'm missing something easy, at least something I should be aware of. The stack trace in the js debugger isn't helpful, so it seems there is some processing happening after the hook is called and the js getting the value in drupal settings.


texts:
When creating a newsletter, I have the view mode set to Teaser, but the content printed on the newsletter page doesn't follow the template I have for it, it only prints the fields as specified in the content's type display manager.

Is there any way of having it print the content following the template?


texts: How to Exclude a Specific Node from a Block View

texts:
I know you can exclude the current node from a list view.

What I'm trying to do is exclude a specific node from a block view.

I have a list of the Top 5 Viewed pages I created into a block view, but I'm trying to hide one of them that keeps showing as it's the home page. I'd like to exclude that from the view.

Is it possible? I couldn't find anything in Contextual Filters.

I'm using Drupal 7 btw

Regards
Tony


texts: Is there any rule when to use panels and when to use templates in drupal 7

texts:
I want to know about the panels and templates use cases as i am confused when to use panels and when to use templates as each page can be designed by both the ways then which is the best solution.
 As we can easily layout both the things through html css.


texts:
I want to use ajax call on image button

here is my code.

function clicktell_form_alter(&$form, &$form_state, $form_id) {

    if($form_id=='user_profile_form') {

       $form['linkb'] = array(
            '#type' => 'image_button',
            '#href' => '',
            '#title' => t('something'),

            '#name' => 'linkb',
            '#ajax' => array(
                'method' => 'html', // this is important without this if else condition for ajax will not work.
                'effect' => 'fade',
                'callback' => 'clicktell_verification',
                'wrapper' => 'replace_textfield_div',),
        );
        $form['cardnresp'] = array(
            '#type' => 'hidden',
            //'#default_value' => '',
            '#title' => t('This is where msg comes'),
            '#prefix' => '
',
            '#suffix' => '
',
        );
        $form['#validate'][]='clicktell_error';

    }
    return $form;
}

and

function clicktell_error($form, &$form_state) {
  //my code
}

function clicktell_verification($form, &$form_state) {
 //my code
}

But now when i click on image button it jst refresh the page and no ajax call happnes

Does anybody have idea regarding this

Thanks


texts: Allow User Role To Schedule Content As Different User

texts:
I am creating a "submitter" user role which should be allowed to post articles as different users - what permission do I need to set for this on the "Permission" page under "People" to grant access to the "author" field?

If thats not possible is there a module for it?


texts:
I have a content type called news which I created a template for, node--news.tpl.php. In my template, I call the date field as follows:

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

It displays like so:

  05/01/2015 - 15:25

I would like it to look like this:

  1 May 2015

I need to be able to do so solely through the node template, as making changes directly in Drupal will affect other sites and that is not an option. Is there a way to do that?


texts: Drupal: showing different page layouts based on form data

texts:
I'm trying to build a multi step form. Before the second step I have to process the data inserted in step one and display different layout and form fields based on the results.

I use "drupal_get_form" callback in _menu hooks to display the form, but I think I have to use a different approach, because I can't find a way to specify a template and\or HTML code this way.

What can I do? Thanks!


texts: Send email from non system email address using Drupal API

texts:
From what should be a non-trivial task, I find this very confusing. My requirement is to send HTML email upon webform submission. Here is what I have now.

If from address is set as domain email address (info@domain.com) that is set as system's email address, set via Admin >> Configuration >> System, the email was sent as non HTML email. This is strange, because I dpm the email content before executing drupal_mail, and it shows up as properly formatted HTML. I could tolerate this for now. Here comes the trivial part.

If from address is set as non-domain email address, such as info.domain@gmail.com, the email sent, never reached the recipients, but is logged as sent (I use mail_logger module) under appropriate email key. I have checked spam folder but it is not there either.

My question is, does drupal 7 require the from email address to be that of the same domain or set as system email? (I would have expect a failed message and is logged into mail_logger)

Any suggestions would help.


texts:
So I'm kind of new to Drupal and I apologise if this is a stupid question. But I've been trying to get both FlexSlider and Insert to display correctly in the frontend. I've add them to the basic content content type.

Both modules have an image field and display associated with them and they do indeed show up in the frontend, but if I use the Insert module then the image gets show twice and I can't get FlexSlider to appear before the content.

The Edit screen displays correctly:

You can see the slider image field is before the body content and title as I've defined in fields and there is only one image upload and an insert button which works as expected.

But then if you look at what is output on the home page:

You can see that (a) the slider is showing at the bottom of the page and (b) the uploading images are displayed unless I delete them after uploading and inserting them.


texts: How do I limit the node count of a content type to one per user?

texts: I have a custom content type. I would like to limit that each user can only create one node of this content type. How can I achieve this?


texts: How to show views calendar by node field_date

texts:
I have a date field with start,end dates.

But i can't understood how to show it in a views block by contextial filter date -> content from node

Thanks for any help!)


texts: How to assign certain themes to certain to Content Types?

texts: I am trying to assign certain themes to certain content types. Is there any way to do this in the admin configurations? I don't particularly want to use a module or modify php code for this.


texts: D8 Programmatically change page orientation for Entity Print module

texts:
In many projects, some entities needs to be printed on LANDSCAPE format, others, on PORTRAIT.
I was searching for an example or, maybe, a more precise way to implement a page orientation hook, but didn't really find any.
I just need to do something like

if($entity_type = "foo"){ set page orientation to portrait }

On this issue, benjy wrote :
If you need to do this programatically, see PrintEvents::CONFIGURATION_ALTER

I looked at the code and saw TestEngineConfigurationAlter class. So I tried to replicate this in a custom module, but it doesn't seem to do anything. I'm obviously missing a piece of the puzzle and I'm humbly asking for help.

Thank you very much :)

Related issues on drupal.org

2797877: Setting paper orientation for dompdf?
2715875: Setting paper size for dompdf in D8


texts: How to load a customer profile from address module

texts:
I'm using Drupal 8 with the module Commerce  and I have an issue with the customer address.

I'm developing an export custom module in D8, and I'm stuck trying to load the profile (to access billing and shipping address) of a customer.

I'm not able to access this data from the custom module. And there is no documentation about the address pluggin ( https://www.drupal.org/project/address )

I have tried to load the order and the user data but there is no relevant field that helps  me to achieve this.

Can anyone give me a hint?

Thanks in advance.


texts: Clear only CSS/JavaScript cache when files are aggregated

texts:
When aggregating CSS/JavaScript files using performance page in Drupal 8, drush cc css-js doesn't work, and I've to clear/rebuild all cache.
How do I properly clear/rebuild only the JavaScript/CSS cache?
I want that the filenames change too, so that the browser resets its cache too.


texts: What's the best way to spell-check a complete Drupal site?

texts:
I'd like to spell-check a complete site (some 300 pages) and my plan is this:

Spell-check complete site to collect all misspellings from all pages
Make a spelling dictionary to be shared by all editors
Rerun spell-check to get list of pages with misspellings
Install TinyMCE spell-check module over aspell, using spelling dictionary from 2
Get the editors to go over all misspelt pages and fix them

How can I run the complete spell-check in 1 and 3? I can hack it with wget, aspell and perl but is there an easier solution?
Can I present the misspellings from 3 in context, highlighted in the page?


texts:
On Drupal 8 we're getting a few deadlock conditions - most connected with the cache. There are quite a few answers to this issue but not so much for D8 (which has very different caching mechanism). Is there any way to resolve/mitigate?

Drupal\Core\Entity\EntityStorageException: SQLSTATE[40P01]: Deadlock detected: 7 ERROR: deadlock detected DETAIL:
Process 9131 waits for ShareRowExclusiveLock on relation 8341492 of database 8341380; blocked by process 9130.
Process 9130 waits for ShareRowExclusiveLock on relation 8341562 of database 8341380; blocked by process 9131.
HINT: See server log for query details.: LOCK TABLE {cache_bootstrap} IN SHARE ROW EXCLUSIVE MODE;
Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
    (line 847 of /var/xxx/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).


texts: How to query for null in nested db_or conditional

texts:
I am trying to perform a query as listed below (notice the check for NULL)

$query = db_select('node', 'n');
/* add fields and joins... */
$query->condition(db_or()
      ->condition(db_and()
                  ->condition('join_alias1.field_date_unassigned_value', NULL, 'IS')
                  ->condition('join_alias2.field_date_assigned_value', $end_date, '<='))
      ->condition(db_and()
                  ->condition('join_alias1.field_date_unassigned_value', $start_date, '>=')
                  ->condition('join_alias2.field_date_assigned_or_submitted_value', $end_date, '<=')));

I am aware that Drupal expects Null values to be checked like

$query->isNull('myfield');

But I don't understand how to perform a query like I listed above while using $query->isNull().

Any ideas? Thanks


texts: Change CSS class based on number (length) of entity reference items, in a paragraph entity

texts:
In my paragraph twig file paragraph--call-to-actions.html.twig, I want to render and build up the entity reference items (the child items from a certain Paragraph type).

There could be 3 or 4 items. Based on the length of the items (3 or 4) I want to change the markup/change a CSS class so I could have 3 or 4 columns.

In paragraph--call-to-actions.html.twig I could do something like:

{% if content.field_call_to_actions|length == 3 %}
  {# Build 3 column item markup here #}
{% elseif content.field_call_to_actions|length == 4 %}
  {# Build 4 column item markup here #}

But how do I loop through my entity reference items (Paragraph type items) so I can print all of the fields of my paragraph type?

Or is there a cleaner approach?

Update:
I found a solution by extending field.html.twig to field--paragraph--call-to-actions.html.twig and in there:

{% for item in items %}

  <div class="card mx-6 md:mx-4 mb-6 md:mb-0
  {% if items|length == 3 %}
    md:w-1/3
  {% elseif items|length == 4 %}
    md:w-1/2 lg:w-1/4
  {% endif %}
  ">
    {{ item.content }}
  </div>

{% endfor %}

I can't use loop.lenght here because of the different breakpoints.

Can I write this more cleaner without duplicate classes (DRY)?


texts: Passing an object to settings using drupal_add_js

texts:
I'm working on a module that will generate a graph using Google's chart api.  The data used to generate the chart uses date objects because I'm graphing race times, like this

[
    ['Number', 'Time'],
    ['1', new Date(2014, 5, 5, 0, 1, 47, 470)],
    ['2', new Date(2014, 5, 5, 0, 1, 45, 880)],
    ['3', new Date(2014, 5, 5, 0, 1, 43, 520)],
    ['4', new Date(2014, 5, 5, 0, 1, 40, 670)]
]

I want to generate this using PHP and am having trouble passing this to the script.  The code I have to generate the data looks like this

$jsData = array();
$jsData[] = array("Number","Time");

foreach($records_nodes as $node) {
  $number++;
  $uTime = strtotime("2014-01-01 0:$time");

  $hundreths = isset($node->field_racetime[$node->language]) ? substr($node->field_racetime[$node->language][0]['time'],-2) : 0;

  $jstime = sprintf("new Date(%d,%d,%d,%d,%d,%d,%d)",
      2014,
      1,
      1,
      12,
      date("m",$uTime),
      date("s",$uTime),
      $hundreths  * 10
  );
  $jsData[] = array("$number",$jstime);
}
drupal_add_js(array('records_view' => array('data' => $jsData)), 'setting');

This works well. I can see the data being passed to Drupal.settings.records_view.data. However, the second element (the new Date part) is being passed as a string:

['1', 'new Date(2014, 5, 5, 0, 1, 47, 470)'],

Is there a way to pass this as the JavaScript object?


texts: Massive spam users and spam entries despite triple layer protection

texts:
I'm going a little nuts here. The entire point of my site resides on the idea of people registering for the site to contribute content. But I get spam accounts created at least once every minute. Im mass deleting these accounts and the content they create every single time I visit my own site.

I currently use Mollom with the CAPTCHA as the default method (not text analysis) and I have text analysis set to every other form across my site, I use the AntiSpam module set to and properly configured Akismet (had good results from Wordpress), and also have Spamicide enabled and properly configured.

But spam users are still being made in some very insane amounts, and generating content all over my site; which leads me to wonder if they're even using the forms at all any more to generate content on my site..

EDIT
may have been a little paranoia but I changed the user credentials to my database just to be sure. And yeah, user accounts by the dozens still being created..

I just tried out the Spamicide module by exposing the form element with Firebug and writing anything in it. Sure enough the form doesn't register the account.

The Captcha works perfectly too.

Note: I understand Captchas is not good enough (Spam bots these days can solve captchas), but its the only option I get from Mollom.


texts: Display random value from multi-value field in Views

texts:
I have an image field that allows unlimited values, and I need to use Views to display a random image from a node's image field. The View should display a random image from that node's field each time the page is reloaded. How can this be accomplished?

Example:

On page load, display image "1" from Node A's multi-image field.
Reload page, display image "3" from Node A's multi-image field.
Reload page, display image "2" from Node A's multi-image field.
Reload page, display image "3" from Node A's multi-image field.

Thanks!


texts: Create user without password using rest api

texts:
From this documentation, currently what the User Registration resource does is to register a user that requires password in the Rest API.

Our goal is to call/use this api endpoint http://localhost:8080/user/register?_format=json to create a user once validated via facebook and dont want to have password in the json.

This is what Im getting when tried to remove the pass field

{
    "message": "No password provided."
}

from

{
"name": { "value": "test03" },
"mail": { "value": "test03@gmail.com" }
}


texts: How to update taxonomy term of a node using services

texts:
I have created a new node using Services 3 module successfully, the code is below

{

 "type":"page",
"title":"New test page",
"taxonomy": {
       "tid" :"367928"
      }

}

Configuration:

Drupal version = 6.26,

url = serviceurl/node,

App = Postman application in chrome,

Method = POST,

data = json.

But when i tried to edit the taxonomy term of the node using same format as below , its not working

url = serviceurl/node/node-id,

Method = PUT,

data = json.

{

"type":"page",
"title":"New updated title of the Page",
"taxonomy": {
       "tid" :"367930"
      }
}

When I checked the node, the title is getting updated where as the taxonomy term remains the same.
I searched a lot on the net, but could not find any solution. Can anyone please help to fix this issue.


texts:
I want to create two modules for two forms. How can I achieve that?
Namespace of both file will get conflict or not?

I am trying for this, and getting one error don't know its because of the two form or not.

Folder structure1:

modules->custom->amazing_forms
                   ->amazing_forms.info.yml
                   ->amazing_forms.routing.yml
                   ->src
                       ->Formss
                          ->ContributeForm.php

Folder Structure2

modules->resume
           ->resume.info.yml
           ->resume.routing.yml
           ->src
              ->Form
                 ->ResumeForm.php

Error:

InvalidArgumentException: Class "\Drupal\amazing_forms\Formss\ContriForm" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 29 of C:\xampp\htdocs\drupal8\core\lib\Drupal\Core\DependencyInjection\ClassResolver.php).

I have a question: Controller name should be Form only or we can use any other name for other modules as I have used above?


texts: Third party library added via composer.json but how can I load it in a module now?

texts:
I have set up a module in my Drupal 8 project to handle some tasks I need doing using AWS.

I added the awssdk (for PHP) to my composer.json and ran the composer update command successfully. the AWS SDK is now sitting nicely in my /vendor directory under the folder aws.

Composer entry

'aws/aws-sdk-php': '^3.0'

I cannot seem to get this to load within my custom module. I have tried referencing the SDK as follows at the top of my one Controllers (After the use keyword but before the class keyword)

require_once (\Drupal::root() . '/vendor/autoload.php');

The result of trying this gives me a blank white page with this error in the apache log:

  PHP message: PHP Fatal error:  require_once(): Failed opening required '/home/dash/public_html/docroot/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/dash/public_html/docroot/modules/custom/awsintegration/src/Controller/AwsiInstanceListController.php on line 9

Also tried using an absolute path as

require '/home/dash/public_html/vendor/autoload.php';

Result: Page loads no watchdog error but I get an apache php error as soon as I try reference one of the SDK classes:

  PHP message: PHP Fatal error:  Class 'Drupal\awsintegration\Controller\Aws\Sdk' not found in /home/dash/public_html/docroot/modules/custom/awsintegration/src/Controller/AwsiInstanceListController.php on line 27

UPDATE

After Clive's suggestion in comments I removed the require calls. I then added some simple code that used AWS to try create a credentials provider, I simply get errors in the apache log about missing Class as per:

  PHP Fatal error:  Class 'Drupal\awsintegration\Controller\Aws\S3\S3Client' not found in /home/dash/public_html/docroot/modules/custom/awsintegration/src/Controller/AwsiInstanceListController.php on line 21

My code is as follows:

namespace Drupal\awsintegration\Controller;

use Drupal\awsintegration\AwsInstances;
use Drupal\Core\Controller\ControllerBase;

use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;

class AwsiInstanceListController extends ControllerBase {

    public function content() {

        $s3 = new Aws\S3\S3Client([
            'version'     => 'latest',
            'region'      => 'eu-west-2a',
            'credentials' => [
                'key'    => 'AbAbAbAbDcDcDc',
                'secret' => 'QwertyQweRty'
            ]
        ]);

        return array(
            '#type' => 'markup',
            '#markup' => $this->t('Hello, World!'),
        );
    }

}


texts: Form submit POST renders page before submit handler is called

texts:
I have a search form in the header that is simply adding a search term to the current URL. If you are on example.com/list-page and submit a search, it just sends you to example.com/list-page?search=my-term-here.

When I submit the form, I've noticed that the full page has to be rendered before the form's submit handler is called. Since the search modifies the current list page's results, it seems redundant when submitting a search for "my-term-here" on example.com/list-page to have to render example.com/list-page again before the submit handler is called and then render the version I actually want: example.com/list-page?search=my-term-here.

I've hacked around this by doing this in my form:

// Set to the current path so we can redirect back there after submit.
$form['submission_path'] = array(
  '#type' => 'hidden',
  '#default_value' => current_path(),
  '#weight' => -100,
);

$form['#action'] = url('search-callback');

The search-callback does nothing:

function mymodule_search_callback() {
  return '';
}

The submit handler then does a redirect like this to get back to example.com/list-page?search=my-term-here.

// Redirect back to the page that submitted the search.
$form_state['redirect'] = array(
  $form_state['values']['submission_path'],
  array(
    'query' => array(
      'search' => urlencode($search-term),
    ),
  ),
);

Is there a better way to handle this? Can the form's submit handler be called before rendering the page the form is posting to?


texts: Find an entity that most recently referenced a particular entity

texts:
Scenario
A content type - Wardrobe references another content type Product via Entity Reference field - field_product.
Problem Statement
I need to find the Wardrobe content which most recently referenced a particular Product content.
Question
Could this be accomplished through Views alone (by playing with available options in views) or do I need to write a customised query in php? I cannot figure out the way with either of these options :/
P.S.
Alternative suggestions are welcome :)


texts:
I've followed this thread https://groups.drupal.org/node/240678#comment-782543, but that's based on a date field and it has a different scenario.

My idea is: When a new content is created, after 30 days will be automatically unpublished.

How can I achieve this without using additional date fields?


texts:
Drupals Leaflet uses the Mercantor projection for leaflet, I would like to have a polar-projection. Is this possible? Any ideas of how to make this possible becuase I dont seem to find anything

Thanks!


texts: How to rewrite the out put of field in view

texts:
In view for title, I have rewrite the output as link and passing other view link. But after doing this also its not taking to the page link for that node.

Why is this? I am doing mistake?


texts: Would PHPLint's advice be beneficial to our community?

texts:
I recently found this static PHP code analyzer called PHPLint. One of the things it can do, is look at code like this:

/**
 * @return string
 */
function getText() {
  return 5;
}

And complain that a 5, is not a string. It seems to me like this could potentially reduce bugs, and perhaps even security issues in our code. One nice thing is that I see it could give is that for return values from function, all you ever need to check is (=== null). If it's not null, then you have the data you expected.

At the surface, this seems like a possibly great addition to our codebases, core and contrib alike. But perhaps there are problems with this that I don't see?

I started applying appropriate doc-blocks to own of my own modules, and one of the issue I hit myself is that because core frequently uses arrays with mixed data in them, there are limits to what kinds of checks PHPLint can do, which causes a lot of warnings.

Edit: One concrete example of an issue that this could prevent is this notice from php 5.4. This code has always failed, it's just that no one noticed until PHP 5.4 made the implicit casting a notice. In this case the bug is relatively harmless, but more subtle errors and security problems could creep in this way.


texts: No submit button available when using Display Suite Forms to render a node add form

texts:
I've created a Display Suite layout and assigned it to my content type.

Everything else is rendered just fine on the form but there's just a "small" problem: no submit button.

Do I need to use some special variables in template file to render submit button?

Current template is(nothign):

1

          <?php print $row_first_col_first; ?>

          <?php print $row_first_col_second; ?>

          <?php print $row_first_col_third; ?>

2

          <?php print $row_second_col_first; ?>

          <?php print $row_second_col_second; ?>

          <?php print $row_second_col_third; ?>

3

          <?php print $row_third_col_first; ?>

            <?php print $row_third_col_second; ?>

              <?php print $row_third_col_third; ?>


texts: Modify tpl file to print the path to the image instead of the image itself?

texts:
I need to change this tpl file which generate images for a image field to print  the path to image instead of the image itself.

This code print out the images. It works fine

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php if (!$label_hidden) : ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item) : ?>
      <span class="<?php print $delta % 2 ? 'odd' : 'even'; ?>"><?php print render($item); ?>
    <?php endforeach; ?>

I need to print just the path to the image (not the image).
I tried with this code but I get a error message related to line 58. (see the error message below)

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php if (!$label_hidden) : ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item) : ?>
      <?php dpm($item); // I uploaded a capture of this dpm

          echo $item['#item']->uri; // THIS IS LINE 58

     ?>
    <?php endforeach; ?>

Error:

  Notice: Trying to get property of non-object en include() (line 58 de
  /Applications/MAMP/htdocs/lembassade.com/sites/all/themes/omega_subtheme_2/templates/field--field-im-genes-del-fondo.tpl.php).


texts: How to determine module path in drush which is outside of Drupal root?

texts:
I've downloaded Coder (7.x-2.x) module in the following way:

drush -y dl coder-7.x-2.x --destination=~/.drush && drush cc drush

And I would like to call function (coder_review_reviews()) from drush (using eval) which is defined in ~/.drush/coder/coder_review/coder_review.common.inc and I need to include that file first, but I don't know how to determine my module path.

Normally when module is within Drupal root, you can use module_load_include() for that, but this function is not available when you're calling drush outside of your core. It seems I can't use dd either.

How can I achieve that without hardcoding the path to the module?


texts: i need help aligning nodes in the views grid style. Each of my rows has 2 nodes but the problem am facing is that they are not aligned. in each row one node is slightly higher than the other. How can i create fixed grid dimensions so that each row is inline?


texts:
I'm building a CSV file and serving it up as a downloadable file.  Pretty straightforward.  Thing is, I get 18 leading empty rows in my csv file.  Any ideas?  I've stripped the code down to just about nothing - should I be looking for problems somewhere else?

/**
 * Implementation of hook_menu
 */
  ...
  $items['providers/dashboard/generate-csv/%/%'] = array(
   'title' => t('Export CSV Data'),
   'page callback' => 'generate_csv',
   'page arguments' => array(3, 4),
   'access arguments' => array('administer module_name content'),
   'type' => MENU_CALLBACK
  );
  return $items;
}

/**
 * MENU_CALLBACK function
 */
function generate_csv($source_type, $include_unpublished = FALSE) {

  // start up headers
  $csv_name = $source_type . '-csv_' . date('Y-m-d') . '.csv';
  header('Content-Type: text/x-comma-separated-values');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Cache-Control: private', false); // required for certain browser
  header('Content-Disposition: attachment; filename="' . $csv_name . '"');

  // write csv data
  $test_output = "test,test,test";
  print $test_output;
}

EDIT - Looks like it is an issue with the headers, not the content.  If I write the contents of my output to a file, I do not have any extra space at the beginning.  Does anyone know:

What's up with the headers that could be causing the extra spaces?  Or..
How can I ditch any output and start over fresh with my headers?


texts:
I am creating a new module in drupal 7 called coolmodule and I'm trying to figure out how to bind content to the file sites/all/modules/coolmodule/coolmodule.tpl.php file.  Here's the block view code in my coolmodule.module;

function coolmodule_block_view($delta = '') {

    $block['subject'] = t('My Special Module');

    $block['content'] = theme('coolmodule', array('myvar' => 'helloworld'));

    return $block;
}

But for some reason, pages with this block does not render sites/all/modules/coolmodule/coolmodule.tpl.php.  What am I doing wrong?


texts: Css from zenbased theme not getting processed

texts:
I have something weird going on. My font-style of my zen-based custom theme is arial, verdana, sans-serif but what's showing is a serif font type.

I checked all the following:

CSS compression turned off.
flushed caches
Activated a different theme and set it as default, then changed some css and it worked so now I know it has to do with the zenbased custom theme.
Went into the file manager of my host's cpanel directly and made changes to my stylesheets directly to see if changes would make any effect on the site but no success.
The site is run on hostgator
checked to see if stylesheets are mentioned in the info file in a
proper fashion


texts: Can regions be printed within a node template?

texts: Can regions be printed within a node template, or are regions strictly confined to page templates?


texts: How can I process a node form from a custom submit handler?

texts:
I have a use case where I have a custom submit button on a node edit form that will take the user off to another page to do some other editing.

If the user has made some changes to the node, such as changed the title, I need to save the current node before redirecting them off to the new page (along with some other generated ID's).

For the life of me, I cant seem to see how I can save the changes to the node in my custom submit handler.
I have tried using $formState->prepareCallback('::submitform()) but that doesn't seem to do what I expected of processing the form.

Anyone done this before or got any good ideas?


texts: Ajax 500 error for filed display changes and file uploads

texts:
A few days ago I found that I can't upload anything or change filed display settings.

It happened after I changed php maximum file upload size value in the host.
I use drag&drop file upload module for my uploads.

This is the error that I'm getting:

One Ajax HTTP error occured
Response code HTTP: 500
debugging error:
path: /file/ajax/---myfolder/und/form-dtByfNu5WvkVK9GJmKiz9WqnkgP-8Z_WofOAxnss7zA
Status code: Internal Server Error
ResponseText: [{"command":"settings","settings":{"basePath":"/","pathPrefix":"","ajaxPageState":{"theme":"---","theme_token":"----"}},"merge":true},{"command":"insert","method":"replaceWith","selector":null,"data":"\u003Cdiv class=\u0022alert alert-block alert-success messages status\u0022\u003E\n  \u003Ca class=\u0022close\u0022 data-dismiss=\u0022alert\u0022 href=\u0022#\u0022\u003E\u0026times;\u003C/a\u003E\n\u003Ch4 class=\u0022element-invisible\u0022\u003E\u067e\u06cc\u063a\u0627\u0645 \u0648\u0636\u0639\u06cc\u062a\u003C/h4\u003E\n\u0641\u0639\u0627\u0644\u06cc\u062a \u062f\u0631 \u062d\u0627\u0644\u062a \u0646\u06af\u0647\u062f\u0627\u0631\u06cc. \u003Ca href=\u0022/admin/config/development/maintenance\u0022\u003E\u0622\u0646\u0644\u0627\u06cc\u0646 \u0634\u0648\u06cc\u062f.\u003C/a\u003E\u003C/div\u003E\n\u003Cdiv class=\u0022alert alert-block alert-danger messages error\u0022\u003E\n  \u003Ca class=\u0022close\u0022 data-dismiss=\u0022alert\u0022 href=\u0022#\u0022\u003E\u0026times;\u003C/a\u003E\n\u003Ch4 class=\u0022element-invisible\u0022\u003E\u067e\u06cc\u063a\u0627\u0645 \u062e\u0637\u0627\u003C/h4\u003E\n\u06cc\u06a9 \u062e\u0637\u0627\u06cc \u063a\u06cc\u0631\u0642\u0627\u0628\u0644\u200c\u062a\u0631\u0645\u06cc\u0645 \u0631\u062e \u062f\u0627\u062f. \u0641\u0627\u06cc\u0644 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc\u200c\u0634\u062f\u0647 \u0627\u062d\u062a\u0645\u0627\u0644\u0627 \u0627\u0632 \u062d\u062f\u0627\u06a9\u062b\u0631 \u062d\u062c\u0645 \u0641\u0627\u06cc\u0644 \u0645\u0648\u0631\u062f \u067e\u0634\u062a\u06cc\u0628\u0627\u0646\u06cc \u0627\u06cc\u0646 \u0633\u0631\u0648\u0631 (64 \u0645\u06af\u0627\u0628\u0627\u06cc\u062a) \u0641\u0631\u0627\u062a\u0631 \u0631\u0641\u062a\u0647 \u0627\u0633\u062a.\u003C/div\u003E\n","settings":null}]

Please note that I reseted all of my changes in php config, even I replaced all of my drupal core files(except sites folder) with the new one file but the problem didn't solve.

What should I do with this?


texts: Automatically add users to the same group as their group admin

texts:
I am using the Organic group module. I created 2 groups on my site. To each group I assigned 1 user as group admin. Group admins have the permission to create users.

My question is how to automatically assign the users which got created by a group admin to the group admin's group?


texts: How do i disable price, shipping and payment in ubercart

texts:
I need to set up a "shopping cart" to allow users to collect URLs from my local database. All my products are free. Based on which URLs are in the users "basket" I fetch files and pack them in a tar file and send the user a URL where the tar file can be downloaded.

How can I turn off or hide price, payment and shipping in ubercart?


texts:
Currently I want to apply angularjs to my drupal site. The problem is:

It is very hard to me add ng-model attribute to a form input tag.

Is there any way that I can add attribute to a form input tag?

Cheers!


texts:
I am currently making a site that will implement a system of volume licenses and I am using a system of checking user registration info to check for certain rules.
My rule works like this

i. On the event of a new user being generated

ii. Check for two conditions present in the user registration info

Check one AND Check two

iii. Grant the user a certain permissions role.

Problem: I need this rule to only work for X amount of users they have added with X being the amount of users that is allowed for with their volume license. I do not know a way nor can I find a way to check against how many times a rule is ran and then disables the rule if a certain number of users have received a role this way. Any ideas?


texts: Contextual Filter from a select list (Key|value) - Use value rather than key

texts:
I have a Content type called Article, under which I have an article type field, which is a select list/dropdown field. The options of the field is as follows:

0Editorials|Editorial
2Feature|Feature
5Spotlight|Spotlight
6Special|Portraits
3Perspective|Perspective
8Research in Translation|Research in Translation
7Columns|Column
4Interviews|Interview
1PhotoEssay|Photo Essay
0Introduction|Special

The reason I have numbers in the key is so that I can sort the results in a particular view in the order I want to (This view pulls results from multiple article types and I want them custom sorted).

Now, I have another view whose path is /articles/%, where the view pulls articles from a particular article type based on the contextual filter provided by the URL.

The issue I'm facing is, The contextual filter value is actually the "key" of the article type field.

For example, /articles/2Feature pulls articles having the article type as Feature, but /articles/Feature doesn't work at all.

I don't want to use the key for both the path and the title. Can I use the label rather than the key for both?

Hope the question is clear. Thanks.

Kaushik


texts:
I want to build kind of a search form in Drupal 8: On submit, it shall load itself again, but below the results shall rendered. And the URL shall contain the search term, so that the result page is linkable.

This is my minimal example. My current problem ist, that the submitted form value is not fed to $form_state.

public function buildForm(array $form, FormStateInterface $form_state) {

  $form_state->setMethod('get');

  $query = $form_state->getValue('query');
  // Unfortunately, this is empty, even after submit.

  $form['query'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Query'),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this->t('Search'),
  );

  return $form;
}

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_state->setRebuild();
  $form_state->setAlwaysProcess(TRUE);
}

When I comment out $form_state->setMethod('get');, it is working as I want: query is readable in the rebuild form and set as default value in the text field.

But with setMethod('get');, query is empty and no default is set.

I thought that $form_state->setAlwaysProcess(TRUE); makes sure the values get processed, even via GET method, as the documentation suggests. But apparently, something is missing. Any ideas, what?


texts: Adding a custom subject field to the Revision Information Drupal 7

texts: I would like to be able to add a subject field to the Revision Information along with the log message. Is there any way I could do that?


texts: Some links are still visible after logging out in drupal8

texts: The question is clear from the title itself , after logging out i can see some view links , one on the side navigation menu and two on the main navigation . I checked the view permission , but its same as the other view which are not visible . Any idea ??


texts:
For Drupal 7, in page content type there is a multiple file upload section. Description is enabled for the file upload, but I need to add one more text input for each images to ask user enter the year file belongs to.

I am not very good at Drupal. So if I can find a clear solution it will save my day. Thank you from now.


texts: How can I programmatically insert content via a script or import instead of through the UI?

texts:
I have a custom content type and I now need to create thousands of entries using that type. It would take a very, very long time to go through the interface and add these one by one. I'm hoping there is a plugin, module, or some kind of API so that I can create all of these entries in an excel and simply import them into the database. Is this possible?

I have not been able to get Drush working so that isn't really an option for me.


texts: Additional validation after successful login

texts:
I want to implement some additional validation steps right after a user has logged in to a Drupal site.

So far, I have implemented the additional validation inside hook_user_login. If the validation fails, I am forcing the logout by calling user_logout.

EDIT: Part of the users are authenticated through an external SSO, so altering the login form to add an additional validation does not seem to be a good solution.

Is this the most standard way to do it, or is there a better way?


texts:
I am working with the views-view-unformatted.html.twig file, and I am trying to use the following code.

{{ dump(row.content | keys) }}

The returned value is the following.

/var/www/html/example_site/vendor/twig/twig/lib/Twig/Extension/Debug.php:60:
array (size=5)
  0 => string '#theme' (length=6)
  1 => string '#view' (length=5)
  2 => string '#options' (length=8)
  3 => string '#row' (length=4)
  4 => string '#field_alias' (length=12)

With {{ dump(row.content['#row'] | keys) }} I get the following.

/var/www/html/example_site/vendor/twig/twig/lib/Twig/Extension/Debug.php:60:
array (size=0)
  empty

Based on it being empty, I assume it is not an array and proceed to use {{ dump(row.content['#row']) }}. When I do this I get a 504 Gateway Timeout error. max_execution_time is set to 30.

How do I dump a variable that is too big for dump(var)?


texts: Language specific menu items when adding content

texts: I am building a bilingual site that's English and French.  When I add a content item in English, then go to Menu Settings, click on Provide a menu link, and click on Parent Item drop down menu, I get all the menu items English and French.   How do I get the drop down menu item to display only English menu items if my content is in English language?


texts: CKeditor removes iframes in editor after update to 6.x-1.14

texts:
Similar to this issue on the CKeditor project, CKeditor removes embedded iframes after I've updated the module. Though there is a solution in the first comment for Drupal 7, I can't find a solution for this for Drupal 6.

Is there a solution to this?


texts: Custom language that displays content from two languages

texts:
This is a rehashing of a question I asked previously, but maybe asked the wrong way.

I have a multilingual Drupal 7 site - there are 13 different languages and those sites all have unique translated content on them.

However, there are an additional 5 "languages" we need to account for - an example of this would be Australia. Australia speaks English so we'd like it to display English content, but there is also content that is unique to Australia (which can't display on the English site), so that should be displayed on the Australian site as well.

I'm curious if we can define a custom language (Australia) that can display multiple types of language content (English and Australian).

For example:

Australian Website

Home (English)
About (English)
Products (English)

Product One (English)
Product Two (English)
Product Three (Australian)
Product Four (Australian)

Resources (English)
Contact (English)

Hopefully this makes sense. Any insight is appreciated.


texts: force webform to reload or start from page1 with rules

texts: If for example a field 'start over' is selected, I would like to reload the webform from page 1.  Wondering the best way to do this.  I already have rules and webform validation enabled.  Do I create a custom rule?  Standard rules do not have a redirect url that I can see. Or is there a function to call to start over.


texts:
How do you load a select field with pre-selected items when the Chosen module is installed/enabled?
I am using the following code.
$my_list = array('item1' = 'item1', 'item2' = 'item2', 'item3' = 'item3');
$form['list_info']['my_list'] = array(
  '#title' => t('Select a list to manage:'),
  '#type' => 'select',
  '#options' => $my_list,
  '#default_value' => $my_list,
);

The select field shows up empty. Clicking it reveals the items and I can select them, but I need the field to show up with the items selected.


texts: Load node entity from external script with image URI

texts:
I'm attempting to grab a node from a node ID in an external php script.
With Drupal 7 I used the bootstrap.inc but with Drupal 8 this are a bit different.

I've called Drupal with:

define('DRUPAL_DIR', $webroot);

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Drupal\file\Plugin\Field\FieldType;

$autoloader = require_once DRUPAL_DIR . '/autoload.php';
$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();

require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';

I'm then successfully loading the node with:

$node = \Drupal\node\Entity\Node::load($nid);

I'm able to grab values with:

$node->get('field_test_field')->value

but I'm unable to get a uri for images. If I try and get the target_id with:

$node->get('field_image_field')->value

I get an error and the following in the error log:

Error: Call to undefined function Drupal\\file\\Plugin\\Field\\FieldType\\file_default_scheme() in /var/www/vhosts/rootpath/webroot/core/modules/file/src/Plugin/Field/FieldType/FileItem.php on line 39

Any idea how I get get the image path? The returned node object includes:

[field_image_field] => Array
            (
                [x-default] => Array
                    (
                        [0] => Array
                            (
                                [target_id] => 44595
                                [alt] =>
                                [title] =>
                                [width] => 250
                                [height] => 89
                            )

                    )

            )

Not sure what I missing, perhaps I need to include a namespace or something?
Thanks in advance!


texts: Resolve CORS issue without changing services.yml file

texts:
I have below in routing.yml

sample.post:
  path: '/sample/post'
  defaults:
    _controller: '\Drupal\sample\Controller\SampleController::postData'
  methods: [POST]
  requirements:
    _access: 'TRUE'
    _format: 'json'

In services.yml no change it will be same as default. I don't want to change in service.yml by enabling cors config.

When I call using jQuery.

  jQuery.ajax({
      url: 'http://localhost/sample/post',
      contentType: "application/json",
      type: 'POST',
      complete: function (data) {
        console.log(data);
      }
  });

It gives

  Failed to load http://localhost/sample/post: Response to preflight
  request doesn't pass access control check: No
  'Access-Control-Allow-Origin' header is present on the requested
  resource. Origin 'http://localhost' is therefore not allowed access.

Can I achieve w/o enabling cors config? If I enable cors then it works fine.


texts: What are some ways to implement a hierarchical taxonomy page structure?

texts:
I'm currently trying to decide how to architect a client's site, and they need to have the need to have a hierarchical page structure. This must be able to go at least 3 levels in depth and have the option of exposing various filters.

I would assume that using a view that accepts multiple arguments and using taxonomies would be the way to go about developing this, but I wanted to ask this community if there were any contrib module alternatives I might look into as well.


texts: Run KernelEvents::REQUEST event before hook_node_access?

texts:
I'm doing some central static variable setup for the request and was hoping to use KernelEvents::REQUEST to run first and set the variables.

However, I've found that while the documentation states:

  The REQUEST event occurs at the very beginning of request dispatching.

hook_node_access actually runs before the KernelEvents::REQUEST event handler:

  /**
   * The subscribed events.
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events[KernelEvents::REQUEST][] = ['onKernelRequest', 1];
    return $events;
  }

then in the event listener:

  public function onKernelRequest(GetResponseEvent $event) {
    drupal_set_message(__FUNCTION__ . ': ' . microtime());
  }

and in hook_node_access

then in the event listener:

  public function mymodule_node_accesss(NodeInterface $node, $op, AccountInterface $account) {
    drupal_set_message(__FUNCTION__ . ': ' . microtime());
  }

Output:

mymodule_node_access: 0.76379200 1518995630
onKernelRequest: 0.77758400 1518995630

As we can see from microtime order, hook_node_access runs first. Anyway to make it run after the KernelEvents::REQUEST event handler? thanks.


texts:
I've created a couple custom fields for Users in Drupal 7 via Config > Account Settings > Manage Fields. Mainly a user's real name, company and a welcome message.

I'd like this info to be displayed when the user views their account page (site.com/user/username) but the fields will not display except to my admin account. The fields are set to visible in the display settings and the users are assigned the appropriate permissions to view profiles and other content.

I've tried enabling Profile2 and using it as well but the problem still persists. Any ideas what's going on here? It's driving my crazy!


texts: How does one set up aliases per domain on a multi-domain site?

texts:
I have a site where there are several domains each with different content:

www.domaina.com
www.domainb.com
www.domainc.com

I want to make the alias foobar to different paths on each domain

www.domaina.com/foobar => page/100/14
www.domainb.com/foobar => page/136/12
www.domainc.com/foobar => page/96/14

I would like to be able to create the aliases using tokens and pathauto in my own module.  I've considered Domain Access, but I'm not sure this allows you to create different aliases per domain.

Can someone please confirm what the best approach would be?

UPDATE:

It looks like I can use Domain Path and Domain Access, but looking at the source code of Domain Path, I'd have to add entries for each alias:

$domain = domain_get_domain();
$domain_id = $domain['domain_id'];
$record = array(
    'domain_id' => $domain_id,
    'source' => "node/$node->nid",
    'alias' => $path,
    'language' => isset($node->language) ? $node->language : LANGUAGE_NONE,
    'entity_type' => 'node',
    'entity_id' => $node->nid,
);
drupal_write_record('domain_path', $record);

This is drupal 6 code, so I don't understand why there is an entity_type and an entity_id.  I'm going to be creating aliases to sources that are views with arguments.  Does anyone know how I'd create that record?


texts: How to update failed transaction detail in drupal commerce

texts:
I am using drupal commerce to built a e-commerce site .

My problem is when a transaction is failed or get a late response then the transaction is not created.

Can i create it manually or i have to ? if yes then how?

Or is their any other way to attach my transaction detail to order .

Any help most appriciate. Thank you.


texts: How to configure the YouTube Field and Mediafront modules?

texts:
I was told that the latest dev version of MediaFront has support for the YouTube field module. How do you configure the fields and the modules so that the embedded YouTube video is displayed using the MediaFront player?

What I'm trying to do: I have a content type that allows for YouTube URLs to be copied in it creates a list of all the YouTube videos that were entered in that node. I want MediaFront to use that list of YouTube URLs in the MediaFront player.

Also in the read it says this:

 7. Change the Manage Display settings for Media link.

    Set up the fields in this order and with these settings:

    Field           Label       Format
    Body            Hidden      Default
    Media URL       Hidden      MediaFront Player

    In the Media URL player settings, set the MediaFront preset to
    nodeplayer. Hit Update. Hit save.
            "

I cannot enable the MediaFront player for the textfield "Media URL".


texts: Children links disappear when access to parent blocked

texts:
When blocking access to a page -- its child links get skipped both in code and display.

The block is achieved via an access callback attached to the menu item that checks whether the user is logged in or not.

The desired behavior is to show the links regardless of the login status.

Any hints?

P.S. I'm using drupal6


texts: How to set a $_POST var value as default value for a textfield webform component?

texts:
I need to set a $_POST variable value as the default value for a textfield webform component using Webform 4
In the Default Value field I filled with %post[my$_PostVar] but is not working.
update: it seems like Webform 4 lost the %get and %post tokens comment-6337368
any thoughts...
@googletorp
I installed the Availability Calendars module. This module shows a availability calendar and provide a formlet to allows the visitor to submit a booking.
When this form (the formlet) is submitted this is sent to a webform where the visitor will continue filling the personal data to complete the booking.
Then form let send these vars: $_POST['arrival_date'] and $_POST['departure_date']  to the Webform. Here is why I need to fetch these $_post values in the Webform components

Booking integration by providing a small "formlet" that can post to
(e.g.) a Webform.

and here some part of the Readme file of the module:

Defining the 'complete booking form' webform
-------------------------------------------- This part assumes you are using the webform module.

Define the webform components that the visitor should complete like name,   e-mail, address, number of persons, etc.

Define webform components for the dates that are already filled in:

Begin date (default value: %post[from_display]): the begin date.

End date (default value: %post[to_display]): the end date.


texts:
I am using Media Browser widget for uploading and editing images in nodes. My images are stored using image fields. Is it possible to edit URL of the image after uploading? I would need to achieve:

When I upload file named "foo.png" it has by default the following URL:

  /sites/default/files/media/.../foo.png

I would need to edit filename to "bar.png", so resulted path will be:

  /sites/default/files/media/.../bar.png

(only filename is changed in URL)

I tried to edit filename, since it is possible using Media browser widget. But editing filename does not have affect on change of URL for me. I also tried to use following hook: hook_file_presave
I tried to programatically change uri parameter using this hook. But nor filename change neither uri change affected URL of the file.
When I look in directory sites/default/files/..  I can see that filename is the same as I uploaded it, not affecting my later changes of filename or uri. When I load php $file object, I can see $file->filename and $file->uri properties changed.

Is it possible to change URL of the file (just last part of the URL - filename) after uploading the file?

//EDIT: I tried to do following changes in my hook_file_presave:

function mymodule_file_presave($file) {
 if ($file->type != 'image') {
  return;
  }
 if (!empty($file->filename)) {
   $uri_parts = explode('/', $file->uri);
   $count = count($uri_parts);
   $uri_parts[$count - 1] = $file->filename;
   $file->uri = implode('/', $uri_parts);
   $file->destination = $file->uri;
   }
 }


texts: How can I get multiple values in a RESTful endpoint from a field who points to other resource?

texts:
I have a Drupal 7.x site with RESTful installed (version 2.5) and I want have one endpoint which shows a node view, and add a field which show a index of nodes ,extracted from another endpoint, which have a entity reference field pointing to the first node.

I tried adding 'resource' key in publicFields method but I can only get the first result.

I saw restful obtain a resource view using ResourceFieldEntity class, calling allways view method inside of singleValue method, which only can return first value. It guess it's made in this way because singleValue don't need return more than one value, but in my case its needed, because i need the resource retrieve the complete result.

Here is where method is called, in line 336 of ResourceFieldEntity class.

   try {
     // Get the contents to embed in place of the reference ID.
     /* @var ResourceFieldCollection $embedded_entity */
     $embedded_entity = $embedded_resource
       ->getDataProvider()
       ->view($embedded_identifier);
   }

I solved this creating a custom resource getter class (extending ResourceFieldEntity), and overwrite singleValue method, and called index method instead of view method.

   try {
     // Get the contents to embed in place of the reference ID.
     /* @var ResourceFieldCollection $embedded_entity */
     $embedded_entity = $embedded_resource
       ->getDataProvider()
       ->index($embedded_identifier);
   }

Are there any other proper way to do this?


texts: I have Drupal version 9.1 but the Get JWT on Login module is not available for Drupal 9.x, so I need to downgrade to the latest version of Drupal 8.x. Is it possible to do that through Composer?


texts: How to break up user roles checkboxes into groups?

texts:
When editing a user in Drupal 7 (/user/NID/edit), I'd like to break up the roles checkbox options. By default, it is just one list of roles. Instead, I would like to group different roles together to make it easier to read for the admins.

Ideally, there would be a group name header, followed by a certain subset of roles and then another head followed by another subset of roles, etc.

There is no change to the functionality of the roles.  This is purely a theming exercise.


texts:
I'm using the Feeds and Feeds XML XPath Parser modules on Drupal 7.
While there is no problem importing all other fields (Title, body, etc.), it does not populate the image field in my nodes.

Feeds debug mode shows all paths to be relative, so I'm using Feeds Tamper to rewrite the relative paths to absolute paths (all on the same domain). Still, no images are being saved.

There are no errors displayed on the import page, nor in Drupal logs.

UPDATE: After some more altering the image paths via Feeds Tamper, now the following error is shown in the logs:
    Invalid enclosure ""

Where should I start debugging this?

Thanks!


texts: How can I "merge" two fields when a form is submitted?

texts:
I have a form from a unique content type which has two fields, when I submit that form, I wish the value entered in the second field was "included" in the end of the first field and then the content type saves.

Like

field1, value: "John"
field2, value: "Doo"

but when the content type is saved, this happens:

field1, value: "John Doo" // the space which divide the two words is required as well.
field2, value: "Doo"

thanks.


texts: I am making a custom module and the link to the path appears on navigation menu by default but I am interested it appears on primary menu when module is enabled. Is it possible in Drupal 7?


texts: Weird behaviour when customising views-view-unformatted.html.twig with grouping

texts:
I'm trying to override the views-view-unformatted.html.twig template by an unformatted view that includes a hidden Grouping field.

The default template includes this code:

{% if title %}

{{ title }}

{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}

    {{- row.content -}}

{% endfor %}

When I copy the default template into my theme, this generates the results I would expect:

When I try to modify the code by wrapping a div around the loop that fetches the rows, like this:

{% if title %}

{{ title }}

{% endif %}

{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}

    {{- row.content -}}

{% endfor %}

I get this output instead:

Note that the first two rows are wrapped in the group-content div, whilst the third row is now wrapped in a separate group-content div. There should obviously be only one group-content div, with all rows inside it.

My goal in overriding the default template is to put them all in a separate div, which I can't do from within the views settings, so the fact that overriding the template isn't working defeats the object of the exercise.

Any ideas why this is happening, and how to get around it?


texts: Drupal Commerce age gate on Add to Basket?

texts:
I'm building a Drupal Commerce store for a client and some of the products are alcohol which requires me to add a popup modal with some text about age laws when they click "add to cart".

How can I do this? I've seen the 'add to cart confirmation' module but I want to display custom markup and only for certain products. The other projects I've seen are in the sandbox and not well documented on how they are used.


texts:
My question seems to be obvious but I really don't find the solution.
Well, I want to redirect to my view just after connexion.
I try to use $form_state->setRedirect,but It's seems it needs the route name.
I don't find the route name of my view!
How to get a route name from a path? Or to redirect using the path?


texts: I have created a relation called user-advisor relation between a user and a content type I named Advisor on my Drupal 7 site. I have also created an entityform type called Advisor where I have created an entity reference field that has a list of all of the Advisor content types. What I want to be able to do is have the user submit this form and when it is submitted I want to create a new user-advisor relation with the user and the selected advisor, I am curious as to what would be the best way to do this and if there is a module to do so. I have looked into the Relation Add module but I am not sure if its functionality is what I need or how to use it.


texts: How to get historical content having historical date that happened in current week in Views?

texts: I have a content type having date field contains historical date like 1897-06-15. Now i need to fetch it by week if historical date's week matches current week in Views? How to do it in views.Any suggestions?


texts: Theme hook suggestions for the breadcrumb block

texts:
I'm using the Omega theme with the Delta module.
How can I theme the breadcrumb block using block--breadcrumb.tpl.php?
I want to change the output of the block to something similar to the following.


texts: How do I setup download links for pdf files directly?

texts:
I want to add a pdf file via a file field on a content type,
I want to display a download link, and if the user clicks save it to your computer, as in a normal download.


texts: How to trigger email by comparing date value in node?

texts:
I'm using Drupal 7, with Rules and Rules Scheduler.

I have a content type "Tutorial Class", with fields as below:

Class Date and Time
Feedback requested (Radio button: Yes/No, default
is no)

I would like to create a Rule, so that whenever the cron runs, it will check on all "Tutorial Class" content type.

If current time is larger than "Class Date and Time" field, and "Feedback requested" is no, an email will be triggered and "Feedback requested" will be changed to Yes.

Currently I know how to trigger email after "Tutorial Class" is created, but I can't get the above Rule done.

Any idea of how to set this rule?


texts: How is the class loader set to load the files containing classes?

texts:
I was trying to understand how Drupal 8 initializes the class loader to look for files containing classes in core/lib and modules/*/src.

I found out that the class loader is set to an instance of ApcClassLoader in DrupalKernel::initializeSettings().

  // If the class loader is still the same, possibly upgrade to the APC class
  // loader.
  // ApcClassLoader does not support APCu without backwards compatibility
  // enabled.
  if ($class_loader_class == get_class($this->classLoader)
   && Settings::get('class_loader_auto_detect', TRUE)
     && extension_loaded('apc')) {
    $prefix = Settings::getApcuPrefix('class_loader', $this->root);
    $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $this->classLoader);
    $this->classLoader->unregister();
    $apc_loader->register();
    $this->classLoader = $apc_loader;
  }

Following the methods that are called after that, I cannot find the exact method setting the class loader to correctly find the files containing Drupal classes. I expect it to be done from Drupal code, since the directory layout is very specific for Drupal.

Which method set the class loader to look in the right directories Drupal uses?


texts:
I want to add a placeholder to my all comment form , here is what i did :

template.php

function ThemeName_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'search_block_form') {
        // HTML5 placeholder attribute
        $form['search_block_form']['#attributes']['placeholder'] = t('Serach ...');

    }

    switch ($form_id)  {
        case 'comment_form':
            $form['name']['#attributes']['placeholder'] = t( 'Name' );
            $form['subject']['#attributes'] = array('placeholder' => t('Subject'));
            $form['comment_body']['#attributes'] = array('placeholder' => t('comment'));

            break;
    }

}

nothing happend , Any Help ?

Thanks

Update
Finally i could add placeholder to comment form like this

function sizin_form_comment_form_alter(&$form, &$form_state)
{
    $form['author']['name']['#attributes']['placeholder'] = t( 'Name' );
    $form['author']['name']['#title']= FALSE;

    //Subject
    $form['your_comment']['subject'] = $form['subject'];
    $form['your_comment']['subject']['#title'] = FALSE;
    $form['your_comment']['subject']['#attributes'] = array('placeholder' => t('title'));
    unset($form['subject']);
    $form['your_comment']['subject']['#weight'] = -10;

    //Comment
    $form['your_comment']['comment_body'] = $form['comment_body'];
    $form['your_comment']['comment_body'][LANGUAGE_NONE][0]['value']['#attributes'] = array('placeholder' => t('comment'));
    unset($form['comment_body']);

}

But i couldn't add to textarea(comment Body) ? AnyHelp ?


texts: Related nodes via entity reference connected to an entity reference?

texts:
The Setup:

Three content types:

Lesson Plan
School
District

Via entity references, "Lesson Plan" nodes reference "School" nodes, and "School" nodes reference "District" nodes.

The Challenge:

Construct a Views Block that is shown on "Lesson Plan" node pages that displays other "Lesson Plan" nodes under the same "District" (via the "School").

In other words, show other Lesson Plans from the same District that the current Lesson Plan's School belongs to.

I've tried so many combinations of relationships and contextual filters... but nothing seems to work! Help!


texts: CKeditor to search images on PC instead of server

texts:
I have added the CK editor WYSIWYG to my website.

However I want user to browse their own local PC directory when uploading images and not the server. The default Image module from drupal core does this fine how can I do this with CKeditor?


texts: Adding optional insurance service to existing shipping service

texts:
This is my first question here, sorry if I miss something and for my bad english.
I have a D7 drupal commerce site, and custom wants to add an optional insurance for shipping. There is only 1 shipping service calculated with shipping weight tariff module. At checkout users should be ablen to choice wether buying insurance for shipping or not. If yes I should add 10% of order total with at least 10€ amount.

Thank you very much.


texts: Triggers on node creation of certain content-type

texts:
It is a question that always gets answered by "use rules module." Unfortunately, this site depends heavily on a few actions and triggers already, and a migration is not in order.

Are there trigger-addons, tricks or code to make a trigger on creation of a certain node-type only?


texts:
How I can customize the node edit page? I need to use a custom template for it.
page--node--add-content-type.tpl.php works fine, but --edit--content-type.tpl.php doesn't.


texts: View block filter by taxonomy term (field)

texts:
I am doing some block experiments because I'm new in Drupal and I want to know if I can create a view block to place X(more than one) times in the same page with different results by taxonomy term content.

I have a new content type which its related(a field) to a taxonomy term, and I want to place the same block for each taxonomy term created and inside the block show the created content related to that taxonomy term.

Ex: Imagine you have a taxonomy term called "Vehicle type". We create two terms into "Vehicle type"(car and truck).
Now I create a content type called "Vehicle info" and I create.

I create a new "Vehicle info" content with a field "Vehicle Type" and check Reference type -> Vocabulary -> "Vehicle Type".

So now I want only a Block which can be placed twice in the same page and each block must list "Vehicle type" contents (one will have cars and the other trucks list).

I tried with contextual filters but when I place the block it does not shows to choose cars or trucks terms.

Many thanks :D


texts: Filter SOLR Search result by Relevance / Score

texts:
I am using apachesolr module, i want to filter search result by minimum relevance, i tried following but did not worked, can anyone please help me

In hook_apachesolr_query_alter()

1) Add filter score:[0.5 TO *] with exclude as false
- It display no items

2) Add filter score:[0.5 TO *] with exclude as true
- There is no change in result, it display all items

3) Add parameter q = {!frange l=5}query($qq) and qq =
Getting 400 error


texts: Recording the time it takes to process a form

texts: I have created a form that has a submission button on it. Is it possible to record the time that the submit button is pressed and then, once the form has run, display how long it took to process on the page?


texts:
I've created one custom module to display product review form on custom created block but i'm not able to submit form and also I can't see form name while I checked with inspect element. give me solution please.
Here is my code for it.

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

  switch ($delta) {
    case 'my_module_config':
      $block['subject'] = '';
      $block['content'] = my_module_form();
      break;
  }
  return $block;
}

function my_module_form($form, &$form_state) {

  $form['rating'] = array(
    '#type' => 'label',
    '#title' => t('Rating'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );

  $options = array(1 => t('1'), 2 => t('2'), 3 => t('3'),);
   $form['rating']['options'] = array(
    '#type' => 'select',
    '#title' => t('Rating'),
    '#options' => $options,
    '#description' => t('Give your rating.'),
    //'#access' => $admin,
  );

  $form['comments'] = array(
    '#type' => 'label',
    '#title' => t('Comments'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['comments']['prod_comments'] = array(
   '#type' => 'textarea',
   '#title' => t('Comments'),
   '#cols' => 60,
   '#rows' => 5,
  );

  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Submit Review!'),
  );
  $form['#submit'][] = 'my_module_submit';
  return $form;
}
function my_module_submit($form, &$form_state) {
    drupal_set_message(t('The form has been submitted.'));
}


texts: Twig whitespace controls have no effect on fields

texts:
I am trying to iterate over a Paragraph field and apply a comma after each Paragraph item.

In the field template that outputs the Paragraph, I am trying:

{%- for item in items %}
  {{ item.content }}{{ not loop.last ? ', ' }}
{% endfor -%}

This puts the comma out, but there is a ton of whitespace all over:

I have tried many whitespace control combinations and none seem to have any effect.

How can I remove this sort of behavior entirely? The paragraph field is an entity reference, that renders a view mode, so I don't want to install field delimeter plugin.

edit: Tried the solutions mentioned here:

How remove whitespace on field in twig?

and here:

https://craftcms.stackexchange.com/questions/2789/whitespace-created-when-using-if-statements

as well as in the documentation.

The structure is as follows:

Node -> Paragraph field -> Paragraph (Entity) -> User Reference + Plain text field + rich text

In this context, only the user field is being rendered, and I want to put a comma at the end of each linked name.


texts: apply condition to pages created by user roles

texts:
if(isset($node) && $node->type == 'page') {
}

In the above code, I need add one more condition, so that it get applied on those pages which was created by users having user role "EDITOR" Please help.


texts: menu item  does not get class expanded nor active-trail when at homepage

texts:
I have a menu which has a link to the homepage in it.

This link to the homepage has subItems.
I was hoping for the menu item to expand and show the links of the lower lvl when i was at the homepage.

This does not happen.
It does expand when i'm on one of the pages of the links of the lower lvl.

Is there any way i can expand this menu item when on the frontpage?

version:
 - drupal 7.14
 - Menu   7.14


texts: Display number of tagged nodes for each term in a view?

texts: I have a view of all of the terms in a vocabulary. How can I in the same view list the number of tagged nodes for each term? Thanks


texts:
I want to  show a Add more button that adds an extra text field and the corresponding Remove button.

I followed ajax_example_add_more() to achieve this in Drupal 7. For Drupal 8, I tried with the following code.

class XmlfeedsSettingsForm extends FormBase {
  public function getFormId() {
    return 'formid';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
   // Because we have many fields with the same values, we have to set
  // #tree to be able to access them.
  $form['#tree'] = TRUE;
  $form['names_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('People coming to the picnic'),
    // Set up the wrapper so that AJAX will be able to replace the fieldset.
    '#prefix' => '
',
    '#suffix' => '
',
  );

  // Build the fieldset with the proper number of names. We'll use
  // $form_state['num_names'] to determine the number of textfields to build.
  $form_state->getValue['num_names_parent'] = '';
  if (empty($form_state->getValue['num_names_parent'])) {
    $form_state->getValue['num_names_parent'] = 1;
  }
  for ($i = 0; $i < $form_state->getValue['num_names_parent']; $i++) {
    $form['names_fieldset']['name'][$i] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
    );
  }
  $form['names_fieldset']['add_name'] = array(
    '#type' => 'submit',
    '#value' => t('Add one more'),
    '#submit' => array('::ajax_example_add_more_add_one'),
    // See the examples in ajax_example.module for more details on the
    // properties of #ajax.
    '#ajax' => array(
      'callback' => '::ajax_example_add_more_callback',
      'wrapper' => 'names-fieldset-wrapper',
    ),
  );
  if ($form_state->getValue['num_names_parent'] > 1) {
    $form['names_fieldset']['remove_name'] = array(
      '#type' => 'submit',
      '#value' => t('Remove one'),
      '#submit' => array('::ajax_example_add_more_remove_one'),
      '#ajax' => array(
        'callback' => '::ajax_example_add_more_callback',
        'wrapper' => 'names-fieldset-wrapper',
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  // This simply allows us to demonstrate no-javascript use without
  // actually turning off javascript in the browser. Removing the #ajax
  // element turns off AJAX behaviors on that element and as a result
  // ajax.js doesn't get loaded.
  // For demonstration only! You don't need this.
 // if ($no_js_use) {
    // Remove the #ajax from the above, so ajax.js won't be loaded.
//    if (!empty($form['names_fieldset']['remove_name']['#ajax'])) {
//      unset($form['names_fieldset']['remove_name']['#ajax']);
//    }
//    unset($form['names_fieldset']['add_name']['#ajax']);
 // }

  return $form;
  }
  public function ajax_example_add_more_add_one(array &$form, FormStateInterface $form_state) {
      print_R($form_state);die;
  //$form_state->getValue['num_names_parent']++;
  //$form_state->setRebuild(TRUE);

}
public function ajax_example_add_more_callback(array &$form, FormStateInterface $form_state) {
  return $form['names_fieldset'];

}
public function ajax_example_add_more_remove_one(array &$form, FormStateInterface $form_state) {
  if ($form_state->getValue['num_names_parent'] > 1) {
    $form_state->getValue['num_names_parent']--;
  }
  $form_state['rebuild'] = TRUE;
}

print_r($form_state) in buildForm() outputs the following.

[getValue] => Array
        (
            [num_names_parent] => 1
        )

In ajax_example_add_more_add_one(), the num_names_parent index is missing.

How can I correctly add the Add more button?


texts: How do I show an exposed view filter in a block only on relevant taxonomy term pages?

texts:
I have two different taxonomy term views for different taxonomy vocabularies: the Blog categories the and Product types. I have an exposed filter in a block that is relevant only for the Product taxonomy term.
How do I show the filter block only on /taxonomy/term/* pages for the Product term, without the need to list them explicitly in the block settings?


texts: How to get rid of "Designed by" in the theme?

texts: I am using the business theme in Drupal 7. I was wondering how do I get rid of the "Designed by Devsaran." in the bottom right corner?


texts:
I'm using hook_link_alter() to add specific HTML classes based on the current URL.

Unfortunately this no longer works once render cached. Since this is not a render array, the #cache key doesn't seem to do anything.

How would you solve this?

PS: if you know of an alternative to hook_link_alter() which is available in the theme layer, I'm all ears.


texts:
I've created a custom module that updates content in my page via an ajax call.  I tried it do it with only views but it was too complex because I was loading multiple content types based on organic groups.

So I have a view that I'm rendering from code and in that view I have a colorbox trigger.  The ajax works and the view gets rendered but I cannot figure out how to properly process the inline-colorbox.  Right now it seems to create the colorbox but fills it with default content from the frontpage so I'm not sure what I'm missing.

I re-init the colorbox after the ajax is loaded in the success and it does process the field.

JS Code

(function ($) {
Drupal.behaviors.forums_dashboard = {
attach: function (context) {

  // If changing the select field
  $('#cohort-select-value', context).change(function () {
        var cohort = $(this).val();
        var dataString = "cohort=" + cohort;

        $.ajax({
          url: '/ajax/coaching_summary',
          type: "POST",
          data: {cohort_id: cohort},
          success: function (response) {
            $('#coaching_summary_ajax').html(response);

            //reinit the colorbox
            $('.colorbox-inline').colorbox();
          }
        });
      }
  );
}
}
})(jQuery);

Ajax code in my module:

function forums_dashboard_menu() {
// Ajax callback
 $items['ajax/coaching_summary'] = [
  'title' => 'Update Coaching Summary',
  'page callback' => 'forums_dashboard_update_coaching',
  'access arguments' => ['access content'],
  'type' => MENU_CALLBACK,
 ];
 return $items;
}

function used to print the view is:

print views_embed_view('cohort_user_list','default',$args);
drupal_exit();

here is the html i get after ajax is called

Edit: I forgot to add versions
Drupal 7.56
Colorbox 7.x-2.13
Views 7.x-3.18

Update:  I decided to use a separate page view for the content to load instead of trying to do it inline.  Here is the new cleaned up jquery

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

  // If changing the select field
  $('#cohort-select-value', context).change(function () {
    var cohort = $(this).val();

    $.ajax({
      url: '/ajax/coaching_summary',
      type: "POST",
      data: {cohort_id: cohort},
      success: function (response) {
        $('#coaching_summary_ajax').html(response);
        $('a',context).colorbox();
      }
    });
  });
}}}(jQuery));

The ajax now returns it as follows to create the URL for a colorbox-node link instead which links to the page with the UID as a parameter:

Test User 1

100 Hours

My problem now is that the first time I click the link it displays the entire page with header/footer instead of just the node content which colorbox-node should be doing.  If I close the colorbox and click the link a second time it displays only the node content as expected.  The colorbox URL gets updated when its clicked the first time.  I'm not sure how to replicate this colorbox process so that it works the first time as expected.  Here is the new link after its clicked a first time.

Test User 1

100 Hours


texts: How to enable click-sorting for views table display based on Search API index?

texts:
I'm trying to create a view with table display based on Search API (database search) index, with column-sorting (column set as Sortable in the display settings). However, this option isn't available for my view fields, no matter if they are based on string or fulltext Search API fields. Is there anything I can do to enable this?

I'm using latest Drupal 8.7.x nad Search API 1.12

Edit:

It seems that availability of click-sorting is determined in \Drupal\search_api\Plugin\views\field\SearchApiFieldTrait::clickSortable method. The check inside that fails, because field definition array doesn't contain a search_api field key. So is there anything I can do to add it there?

BTW. th support for click-sorting was added in https://www.drupal.org/project/search_api/issues/2816979. There are some SOLR-related issues mentioned, but noting related to my use-case.


texts: Add unlimited field collections in a from of drupal

texts:
I created a form in drupal for creating a new node. This content type has a field collection with 2 fields, name and amount.
I use the code below  in form and add 5 field collections to form, but when submit the form, only the last field collection is saved in $form_state['values] and 4 elements get lost.
How can I add unlimited field collections to a form by programming?

In my form:

module_load_include('inc', 'field_collection', 'field_collection.pages');
$form['cooking_type']['cooking_materials']  = array();
 for ($i=0;$i<5;$i++) {
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_cooking_materials'));
$form['cooking_type']['cooking_materials'][$i] = array();
field_attach_form('field_collection_item', $field_collection_item, $form['cooking_type']['cooking_materials'][$i], $form_state);
}

in submit form:

$material_name= $form_state['values']['field_material_name']['und'][0]['value'];
$material_amount = $form_state['values']['field_material_amount']['und'][0]['value'];


texts: Is it possible to trigger a webform submit via url?

texts:
I have set up a webform for simple user polling with an yes/no option, with a submit button.

  [ ] Yes
  [ ] No

  Submit

and the parameter is pass via URL as default, e.g.:

 http://example.com/event_form?option=y

Currently, the webform link is sent via email. So users click the link, open a browser, select an option or use the default, press submit, and see the confirmation message.

Is it possible to automate the submit click? Such that the submit button is automatically clicked after clicking on the link in email?


texts: D7 performance issues once uploaded to remote server

texts:
I just recently uploaded my D7 site to a remote server and now seem to have long wait times to do anything. I have caching turned off and am still in development mode. Could it be certain modules I am using. I tried turning devel but still same wait times. What do I need to do to speed things up? everything was quick when I had the site local...

NOTE:
- I am using Godaddy. i would think they have sufficient resources.


texts:
I have installed Fieldgroup module to create groups in node edit form.

However, when I am on Manage fields page (for content type) I cannot add body to a group. Is there any workaround using some hook?

thanks
Tomas


texts: How obtain the uid of the logged user as a related field in a view?

texts:
I have a view showing the nodes of a content type, and I want to show the user ID of the currently logged-in user as a field in view, but I can't find how to add the user ID of the currently logged-in user. I know that I can achieve this with the Views PHP module but I want to know if there is another way.

I have Views 3.11.

There is no relation between the content being shown, and the currently logged-in user; I just want to show the user ID of the user who is currently seeing the view.


texts: Can error messages be avoided for custom modules in the Update manager?

texts:
On my "Available updates" page I get error messages when there are custom modules in use:

  Failed to get available update data for one project.

Is there any way to avoid this?  Either by setting up some sort of feed for custom modules (probably not practical in most situations!) or by excluding custom modules from the list?

(As an aside, it seems like a design flaw in the Update manager module to give an error for custom modules.  If they are in the custom directory inside modules then it can easily determine that they are custom, and clearly should not expect to receive update data for them from the same source as contributed modules.)

Is there any solution to this other than filing a bug report and hoping the maintainer agrees with my perspective?  (Or hacking the module myself.)


texts: Contact form to notify the author of the node

texts:
i am building a real estate website where authorized users will be able to add some properties. I need in the property details page(node) to have a contact form with spesific fields and when that form submitted, the author of the node will be notified by email. Is that possible and how can i do this?

I am not a programmer so i would prefer a solution with existing modules.


texts: Access the row level field of a image field with multiple values

texts:
I'm having issues when trying to get the image URL of an image field, which allows multiple values.

I have a view which has context to a node.

I have two templates, one for the row level of the view, and one for the field level of the view:

views-view--my-view.html.twig:

{% if rows %}
  {{ rows }}
{% endif %}

views-view-fields--my-view.html.twig:

{{ kint(get_image_path(row._entity.field_header_images)) }}

get_image_path():

public function get_image_path(\Twig_Environment $env, array $context, $image, $style=false) {
  // Check if $image is present
  if(is_null($image)) {
    return false;
  }

  kint($image);

  // Object structure different, depending on if node.field_name, content.field_name or row._entity.field_name is passed
  if(isset($image['#items'])) {
    $image = $image['#items'];
  }
  elseif(isset($image['#item'])) {
    $image = $image['#item'];
  }

  // Check $image->entity is set
  if(!isset($image->entity)) {
    return false;
  }

  if(!$style) {
    return $image->entity->url();
  }
  else {
    $image_style = ImageStyle::load($style);
    return $image_style->buildUrl($image->entity->getFileUri());
  }
}

get_image_path() is a function provided by the starter module. It allows you to easily pull out URLs for images (with size support), without having to do the horrible relationship file URI business.

I can't use get_image_path() on fields.field_header_images.content due to its structure, so I have to access the row.

Now what happens is only the first image is returned. So if I had 3 different images, I'd get the URL for the first image 3 times.

If I just use fields.field_header_images.content, I am able to see the 3 different images without issue.

Hopefully I'm not being too unclear/broad!

Thanks in advance.


texts: How do I cache web page for different header parameters?

texts:
I use AWS cloudfront with my drupal site. It sends below value with response headers.

CloudFront-Is-Mobile-Viewer => true

This value is true when you view your site with a mobile. And if this is true the site will load some mobile specific contents.

When using a browser, below response header will appear. And it'll show some desktop specific contents.

CloudFront-Is-Desktop-Viewer => true

Currently whether I open the web page from mobile or PC, the first one will get cached and it will show in the other device too.

How do I maintain two cache objects for this response headers value. One cache for mobile users and other one for desktop users.

I tried below with my_module.theme file

function my_module_preprocess_page(&$variables)
{
    $variables['#cache']['contexts'][] = 'headers:CloudFront-Is-Mobile-Viewer';
}

And once enabled the http.response.debug_cacheability_headers: true the response is showing like below.

But still the page caches for all the devices and looks like issue is not fixed.


texts: Extra text field for Status order in Commerce

texts:
I do have extra order status (Available for download) in Commerce. And when I choose this status I want to add a link to download a file. How can I add extra field for the order?

Probably, I even need two fields: "link" for the link and "text" for the description of link.


texts: How do I programmatically update the rendering language?

texts:
I am trying to programmatically set the Views rendering language of a couple of Views having multiple displays. I found that doing it manually is error prone.
use Drupal\views\Views;

$view = Views::getView('ap_country');
print_r($view->display_id);

$view->setHandlerOption('page_2', 'argument', 'nid', 'admin_label', 'Foo');
$view->save();

I am trying to achieve something like the above and then export the View. However rendering language does not seem to be a handler.
The reason behind dong this is currently all the views are set to the current Interface language and I want to switch to the content language.


texts: Path issues using composer for Commerce install on shared hosting

texts:
On a shared server with Composer installed the template for installing Drupal 8 or Drupal commerce creates a project directory and puts the site in a web directory within the project.

On a shared host with a structure like:

/var/www/example.com

with home private tmp ssl web

How do you use composer to install 3 or more Dupal sites like this?

example.com
example.com/mystore
example.com/dev

If you run the composer install from the web directory /var/www/example.com/web the install paths are:

example.com/projectname/web
example.com/mystore/web
example.com/dev/web

and projectname, mystore and dev are not a protected directory.

Running composer from /var/www/example.com does not work


texts: Disable the navbar in a Bootstrap sub-theme

texts:
I've noticed that the Bootstrap Navbar, while behaving like the 'Main menu' is not available to be enabled and disabled from the blocks admin page, furthermore at the admin menu admin/appearance/my-bootstrap-subtheme/settings there aren't any options to disable it...

Is there a line or option that I can add to the file at...

my-bootstrap-subtheme/templates/page.tpl.php

...that would disable it?

Alternatively perhaps there is something that can be edited inside the (parent) bootstrap file...

bootstrap/theme/settings.inc

around line 105 that would add a 'Disable Navbar' option at admin/appearance/my-bootstrap-subtheme/settings ...

Incidentally where would I put this edited settings.inc file inside my subtheme directory?

Thanks.


texts: How to print meta property using custom meta tag module

texts:
I have implemented the custom meta tag module found here:
http://www.phase2technology.com/blog/creating-custom-meta-tags-with-the-metatag-module/

The following code creates my new meta tag, the problem is that it creates a

<meta name="my_custom_metatag">

tag.

How can I make it print out a

<meta property="my_custom_metatag">

tag instead?

<?php
//
// Implements hook_metatag_info().
//
function my_metatags_metatag_info() {
  $info['groups']['my_metatags'] = array(
    'label' => t('My Custom Metatags'),
  );

  $info['tags']['my_custom_metatag'] = array(
    'label' => t('My Custom Meta Tag'),
    'description' => t('This is a custom meta tag'),
    'class' => 'DrupalTextMetaTag',
    'group' => 'my_metatags',
  );

  return $info;
}

Thanks!


texts: Suggestions for creating a more complex tiered content type

texts:
I need to create a content type where users will be able to create a tiered structure. This will be generated into a PDF and displayed using the Drupal templating system as well.  I will need some sort of multi-valued field so that the user can add as many items as they like. I need the content structure to look like this:

Content Title
Custom Category Title

Custom item
Custom item Subheading

Custom subitem 1
Custom subitem 2

Another Custom item

etc...

I'm considering Multifield (We've used field collection before and had issues with translation)

Or possibly a Custom Field type

If I used multifield, one option might be to have the user specify these things for each item ( Is it a subitem parent?, Is it a subitem?, If it is, what is it's parent?)

This is Drupal 7 and we'll be using Entity translation to handle translating this content type for all of our domains.