texts:
I have the following in my aliases.drushrc.php file --

$aliases['prod'] = array(
    'uri' => 'foo.com',
    'root' => '/var/www/foo/htdocs',
    'remote-host' => '123.456.78.90',
    'remote-user' => 'bob',
    'databases' =>
      array (
        'default' =>
        array (
          'default' =>
          array (
            'driver' => 'mysql',
            'username' => 'foo',
            'password' => 'bar',
            'port' => '',
            'host' => 'localhost',
            'database' => 'foodb',
          ),
       ),
     ),
    'shell-aliases' => array (
        'dump' => '!drush sql-dump --gzip --ordered-dump',
    ),
  );

When I run drush @prod dump it attempts to connect to 'remote-host'. If I comment out 'remote-host' it dumps just as expected. I do need this value though for other functions such as sql-rsync.

I could create a new alias just for dumping but this seems a little excessive.

Any ideas?


texts:
I have a quicktabs on my homepage. When the tabs are clicked the url of homepage changed to like this:

http://www.example.com/home?qt-homepage_tab_menu=0#qt-homepage_tab_menu
.
.
.
What should I do if I only want to have http://www.example.com when any tab is clicked?

Thank you!


texts: Is there a difference between "Clear cached data" button on the performance page and drush cc all?

texts:
Is there a difference in what caching is cleared between

drush cc all

and

Admin > Site Configuration > Performance > Clear cached data button

?


texts: Redirect anonymous user to login in custom module

texts:
In a custom module, I'd like to redirect anonymous users to the login page. After a successful login the user should get to the page he intended to see.

I tried the following code. This gives me the login form, but the user is never sent to the destination page. Instead the standard user page gets displayed.

if (!$user->uid) {
    $dest = drupal_get_destination();
    drupal_goto('user/login', $dest['destination']);
}

Any ideas how to fix that?


texts: Permissions / Roles / Taxonomy / Workbench -- combination?

texts:
Hello dear Drupal enthusiasts,

I'd like to hear your opinion - how to organize mentioned modules/functionality to achieve nice permission granularity.

After user is logged in we have a list of his e-groups (outside structure, we have its names).
I want to build drupal inner hierarchy where I organize user e-groups to tree structure.
I would like to divide nodes to groups, to allow people who are members of some e-groups to edit some nodes (gathered in group).

What comes to my mind it's to organize page structure in one vocabulary, and allow admin to add a e-group name to some taxonomy.

Example:

Main Site admin [taxonomy: egroup-main]

Department A admin [taxonomy: egroup-department-a]
Group 1 [taxonomy: egroup-group-one]
Group 2 [taxonomy: egroup-group-two]

Subgroup 1 [taxonomy: egroup-students]

Group 3 [taxonomy: egroup-group-three]

And now, after somebody logs in first time, and we know he is part of egroup-main, we give this user taxonomy egroup-main, which is the same we set to Main Site Admin term in vocabulary shown in example.

Is there any better way to organize this? I need fine, good grained control over users by egroups, to access, create and delete nodes.
What about workflow management? I mean - module like Workbench is nice to control workflow, let beginner users to edit, and let admins to publish stuff after review.

I know there's a module called Taxonomy Access but it seems it bases on Drupal Roles which means apart from taxonomy we would have to create dynamically user roles (depending on e-groups), attach permissions to them and assing users to these roles...

Waiting for your hints people!

Confused Drupal developer


texts: How can I make views exposed filter case-sensitive?

texts:
When I use the exposed filter, if I search for "IMAG" all results showing image show up.  Is there a way to have the exposed filter search case sensitive?
UPDATE
I added a screenshot to explain more.  I have tried the operators: is equal to, contains, contains any word, contains all words, and regex.  Neither of them are case sensitive.


texts: Why nodes aren't always deleted on cron?

texts:
I have this code in my module_cron function (I need to delete old unpublished nodes).

include_once './modules/node/node.module';
$nids = db_query("SELECT nid FROM node where status = 0 AND UNIX_TIMESTAMP()-changed>172800 LIMIT 2000");
while ($result = db_fetch_object($nids)) {

  echo  "Deleting node ".$result->nid."<br>";
  node_delete($result->nid);
}

It always outputs node ids, but it rarely actually deletes nodes. In fact it seems to totally stop deleting them until I login to admin panel. What am I doing wrong? Is there any way to always delete nodes?


texts: newsletter with export email to csv and import from csv features

texts:
i had use simplenews before, but there is no function to export or import email to csv file.

anyone know any module have such functions?


texts: How can i export data to PDF from an SQL query?

texts:
Given the following code:

$query3 = db_select('1_jp_lomba', 'jp2')->fields('jp2', array('nama_lomba'));
$query3->condition('jp2.jp_ke',$selected,'=');
$options4 = $query3->execute()->fetchCol();

How can I export the data held in the $options4 variable to a PDF, using Drupal 7? Is there any existing API function that will help me with this?


texts:
I want to override the default three-column layout used by the Display Suite module, and I want to use only the left and right columns, without the middle one.
What is the easier way to achieve this?


texts: Where can I find the form API reference?

texts:
Form API Reference gives information about which properties to use for a form array, for Drupal 7.

Where can I see what properties I can use in buildForm(array $form, FormStateInterface $form_state), such as #type, #title, #required? How can I know the other possible properties?

Actually I'm using the Drupal 7 information in Drupal 8, and it works, but there should/must be an updated page, I guess.


texts: Prevent hook_form_alter to works only on frontend not in admin?

texts: I have used a hook_form_alter to alter a form fields value randomly and its working fine, but the problem is that when i open this webform in admin panel its just change the value  which i dont. Its should keep the same value which is submitted by frontend user. i want this hook to work in case of frontend only not for admin.


texts: How do I programmatically update pathauto paths for an entity?

texts:
If an entity has opted into auto generated paths, you could simply re-save the entity. However saving an entity is particularly inefficient, and the path/routing system runs outside of the entity system.

How do I update a path for an entity without saving the entity?


texts: Passing PHP variables to JS file initiated from theme .info file

texts:
I know it's perfectly possible to pass PHP variables to JS but what if the JS file is initiated from the theme.info file? Can you access it in template.php or? Please some advice..

Thanks!


texts: Rules module: How do I execute code just before content is deleted?

texts:
I'm trying to execute some code right before content is deleted. The Rules module has events for

After updating existing content
Before saving content
After saving new content
After deleting content

However, none of these execute my code at the right time. Is there a way to easily add new events? If so, where should I hook? My knowledge of the Drupal core is very small.

Background:

What I'm doing is updating a menu link that links to the content in the database, but as the update code only runs after having deleted the content, there isn't any row to be updated because Drupal apparently deletes menu items that link to non-existent content.


texts:
I have been using void menu and adding the smoothScroll class to the menu links but they only work up until any , any void higher the class="smoothScroll" doesn't get printed.

I am not sure how the first four are getting the .smoothScroll added to them either as i set that up a while ago and can't figure it out how or where.


texts: Drupal Paragraph Type that references a Block from a View

texts:
I have a paragraph type that is called view reference, the field within view reference is an entity reference to a view.

I've recently upgraded my drupal site from 8.3 > 8.4.5. The problem is that now - when I view the rendered node and paragraph type when logged in the view shows. But when I'm logged out the view is not there.

I've looked into the problem and for some reason the field isn't rendering i.e. past the views-element-inner tag, see the following screenshots:

Logged in:

Logged out:

Can anyone help me with a solution?

My plan B is to scrap the view reference paragraph field and replace it with a block field inside my paragraph type with the block field module. Can anyone back me up on this or suggest another solution?

Thanks in advance.


texts: How to download from private// following a link?

texts:
I have a custom entity (contract) created in a custom module (amap) by a bunch of BaseFieldDefinition, one of which being

$fields['file1'] = BaseFieldDefinition::create('file')
  ->setLabel(t('Source file'))
  ->setDescription(t('Source file (may be modified)'))
  ->setSettings([
    'target_type' => 'file',
    'file_extensions' => 'doc docx odt pages',
    'uri_scheme' => 'private',
    'file_directory' => 'contracts',
  ])

I have a View about the custom entity that displays some fields in table mode:

The download action (the yellow arrow) is defined using Custom text with rewrite results, link path being {{ file1__target_id }}:
The link is something like mysite/system/files?file=contracts/Contract-4-20200408.doc (for example).
And following the link gives different results depending on the browser. None of them being what I want: the default filename proposed is not correct 'files' or 'file.dot' instead of 'Contract-4-20200408.doc' (in my example).

So I tried to implement hook_file_download. My code is

function amap_file_download($uri) {
  $sFileName =  \Drupal::service('file_system')->basename($uri);
  $sFileNameWithPath = 'sites/default/files/_private/contracts/' . $sFileName;
  $response = new BinaryFileResponse($sFileNameWithPath);
  $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $sFileName);
  return $response;
}

and there I get this error!

Notice: Object of class Symfony\Component\HttpFoundation\BinaryFileResponse could not be converted to int in Drupal\system\FileDownloadController->download() (line 51 of core/modules/system/src/FileDownloadController.php).
Drupal\system\FileDownloadController->download(Object, 'private')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

What am I doing wrong?


texts: Put off loading my theme banners to speed up Drupal

texts:
I'm currently using the Marinelli theme for a project.  It loads ALL the top banner pictures before showing the page.  Very slow.  Results in a big download size for the home page.  Is there a way to get Drupal or the theme to put off loading all but the first banner pics when it displays the page.  See my screen capture of pingdom.com

Dave


texts: Is the current faceted search effective for SEO?

texts:
Seems that the url generated by faceted items are not good for SEO (unfriendly to search engines) eg. I have a facet that transforms the url to this format : http://localhost/mysite/property-for-sale/residential-sale?f[0]=field_property_type%3A71

I don't know how i can make it more friendly to search engines as this is automatically generated by the faceted links...

any suggestions, is this possible with the current version of facet search apis?


texts: How to assigned specific "comment" view mode for specific "node" view mode?

texts:
In "Article" content type i have three view mode in "Manage Display" namely "teaser", "default" and "abc".

Similary in "Comment Display" i have two view mode namely "defalut" and "xyz".

Eg: When i see "abc" node page where i am listing comments, that time the comment should be display with my "xyz" view mode not the "default" one.

function custom_node_view($node) {
    return node_view($node, 'abc');
}


texts: Modify default rendering of a custom content type defined in a module

texts:
I am developing a module for importing, editing and exporting DocBook(XML) documents. In this module I define two new content types: docbook and  *docbook_section*. I have also defined new fields like: author, keywords, etc.

The default rendering of these content types is not quite handsome, so I would like to change and improve it. The classical Drupal way is to copy the template node.tpl.php to node--docbook.tpl.php and customize it. But this modification is done on the current theme, after the module has been installed. I would like to do the modification inside the module, so that as soon as it is installed it has a decent default look, without having to make any external modifications. Themes should also be able to override this template, in order to customize the look.

It may seem reasonable to place node--docbook.tpl.php inside the module, but that way it will not work: the theme/rendering engine will not be able to find and use the template. To solve this problem, I have defined hook_theme() on the module like this:

/**
 * Implements hook_theme().
 */
function docbook_theme($existing, $type, $theme, $path) {
  return array (
    'node__docbook' => array (
      //'variables' => array('view' => NULL,),
      'template' => 'node--docbook' ,
      'base hook' => 'node',
      'path' => drupal_get_path('module', 'docbook'),
      'preprocess functions' => array('template_preprocess_node__docbook'),
    ),
  );
}

This time it indeed finds the template node--docbook.tpl.php inside the module. Themes can also override the template if they define node--docbook.tpl.php. But I have some problems.

First, I call nowhere the function theme('docbook', $variables), so I don't see where I can assign the variables. Another option can be to assign them on the preprocess function like this:

function template_preprocess_node__docbook(&$variables) {
  $variables['test'] = 'ABC';
}

But this doesn't work either, and in fact, it seems that the function template_preprocess_node__docbook() is not called at all, although it has been listed on 'preprocess functions' as well (at the definition of hook_theme()).

So, I am stuck. Although I have been working with Drupal7 for two years, theme and template processing still seems to me like a huge maze and I am not able to find my way around. Can somebody help me?


texts:
Drupal 7

Is it possible to write an if statement in the page.tpl.php file that first gets the user role and then compares it to a string and it either shows the logo or doesn't. Something like...

//some how get user role

global $user;
$user_fields = user_load($user->uid);

$current_role = $user_fields->role[];

if ($current_role == "public_user"){
>?
<?php
 print $front_page;
?>" title="

<?php
 print t('Home');
?>
" rel="nofollow">

?>
}else{
//don't show.
}


texts:
Most probably because of the naming coincidence with the Token module, I cannot find any tutorial or reference as per how to effectively use the Tokens view mode that I can see in perhaps all entities in Drupal.

I smell this serves some particular purpose but cannot get a clue.


texts: How do I render the page to add products into my custom module?

texts:
Here is my code

<?php
namespace Drupal\mymodule\Controller;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Controller\ControllerBase;
class HelloController extends ControllerBase
{
  public function content() {

       $form = \Drupal::formBuilder()->getForm('\Drupal\commerce_product\Form\ProductForm');
}
}

I want to render the default add to product page(product/add/default) in my custom module controller file .

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


texts: Is a block changed programmaticaly with hook_block_view_alter cached?

texts:
I have a lateral section which will be different for every page in my site, but the content is practically unaltered for every single page.

I had the intention of using hook_block_view_alter. I would create an empty block in the region, and would fill the content dinamically with PHP in a hook in a custom module.

Will the content be cached or should I better create different blocks for every single page and change the content only if the content changes?


texts: Drupal 7 White Screen of Death when adding content type

texts:
When I navigate to /?q=admin/structure/types/add in order to add a content type, I get a white screen of death.
I'm running Drupal version 7.41 on Windows 2008 r2.
Can someone walk me through the steps on diagnosing this problem? Most of the documentation I've found is written for the Linux platform, so it's not very helpful. Thanks.


texts: Set Home link in breadcrumb for items in a particular menu

texts:
I have two menus: Main and Members. My breadcrumbs in the Main menu are working just fine as defaults.

I would like to customize the breadcrumb for any menu item in the Members menu. Specifically, I'd like Home to be changed to Members and the URL to be \members instead of \.

Is there a hook or module that can do this?


texts: How can we divide the price if the customer select certain attributes?

texts:
I am working on a magazine site where the magazine can be subscribed. When users subscribe, we want to allow them to choose between full payment and monthly payment. I have used a "payment_type" attribute for the payment option, and I want to divide the total price by the number of months when user selects the monthly payment option.

How can I achieve this?


texts:
I have an ansible script that transfers a production database to my devel server, then runs a few Drush commands to prepare it (e.g. updating the filesystem settings, clearing the cache).

A more complex task is updating a nested configuration value like the following one.

mail_system:
  default-system: SmtpMailSystem
  maillog: MaillogMailSystem

Supposedly I ought to be able to do this with drush ev (aka php-eval) and variable_get() and variable_set() as with drush7 ev '$v = variable_get("file_public_path")', but I get this error message.

  Error: Call to undefined function variable_get() in /usr/local/bin/drush7.4.0/commands/core/core.drush.inc(1122): eval()'d code, line 1

It does work correctly when I use the interactive shell.

drush7 core-cli
self> variable_get('mail_system');
array:2 [
  "default-system" => "SmtpMailSystem"
  "maillog" => "MaillogMailSystem"
]

I can work-around it by reading the content of $conf easily enough.

drush7 ev 'global $conf; echo $conf["mail_system"]["default-system"];'

Writing involves a database query and clearly variable_set() is in core.

Why cannot I use variable_get() and variable_set()?

I am using Drush 7.4.0 and Drupal 7.59.

(I also have Drush 8.1.16 available, but that's much use for this, Drush 8's cget and cset require Drupal 8, and Drush 8 doesn't have Drush 7's vget and vset.)


texts: How to fetch the field data in computed field

texts:
In  my content type i have range field which have two value from and to. i would like to print the from value only through the computed field.The object array looks like this

[object array]
  [field_range]
     [und]
      [0]
       [from]
       [to]

I tried to fetch the form value by using below piece of code but i am not able to get result. Please anyone guide me to achieve this.

$field_items = field_get_items($entity_type, $entity, 'field_range');
$drilldata = $field_items['und']['0']['value'];
$entity_field[0]['value'] = $drilldata->from;


texts: Views - Contextual filter -  "page not found"

texts:
I have a view that uses a contextual filters of type

  Content: Has taxonomy term ID (with depth)

The page display has the following path /objects/%
If I access the site through http://mysite.com/objects/all the view gets triggered and all my objects are listed, http://mysite.com/objects/silver also works fine (now only objects tagged with silver are listed), but if I use http://mysite.com/objects then I get a "Page not found" message, how can I solve this? I wan't the /objects and /objects/all to show exactly the same content.
Of course I could copy the display and add a path for /objects but that don't seem quite right.


texts:
I'm currently using Drush to migrate a Drupal 7 site to a fresh copy of Drupal 8. Everything is migrated except the image fields.

I get thousands of these warnings with different ID numbers.

  [warning] Missing file with ID 26. ImageItem.php:329
  [warning] Missing file with ID 26. ImageItem.php:329
  [warning] Missing file with ID 26. ImageItem.php:329

I'm also using WAMP to locally migrate the site and maybe I'm typing the destination public file path incorrectly. Here's some of the commands I tried.

drush migrate-upgrade --legacy-db-key=migrate --legacy-root=/wamp64/www/d7 --configure-only
drush migrate-upgrade --legacy-db-key=migrate --legacy-root=c:/wamp64/www/d7 --configure-only
drush migrate-upgrade --legacy-db-key=migrate --legacy-root=/www/d7 --configure-only
drush migrate-upgrade --legacy-db-key=migrate --legacy-root=/d7 --configure-only

What's the command to migrate images too?

Thanks!


texts:
I have created a Flat Rate Service and defined 10 dollars base rate. No calculation rules nothing else. But when I am trying to checkout

Shipping service
No shipping rates found for your order. Please continue the checkout process.

Do I need to define any calculation rules etc..


texts:
Have been struggled with this problems for days and I wonder if someone could have a look at it? I have tried me sleepless to achieve a certain table in views between three content types which has relations between them, using entity reference. The biggest issue is that I can't wrap my head around how I should set up my relations.

Since this is driving me crazy, have I made this pdf that describes what I have now and what I'm trying to achieve.

http://themesh.se/problemDesc/problemdescription.pdf

Hope some of you have some spare time and if the simple answer is "This won't work" will that also be satisfying at the moment.


texts:
First of all I apologize for my stupid question...I am a new user in drupal and I don't know very much about php and css...
My trouble is the following:I have many elements in my website with class "field set" , all I want to do is to have a background and a border style for some of such field set, but I want to set differents style for a specific "fieldset" element! I try with firebug to find the elements and I found this:

      <form action="/completa-proximity" method="get" id="views-exposed-form-home-lista-completa-con-openlayer-page" accept-charset="UTF-8">

                <input type="hidden" name="circle_op" value="&lt;" />

                <fieldset class="openlayers-proximity-filter-exposed form-wrapper" id="edit-circle">

                  È a meno di
                  <input type="text" id="edit-circle-value" name="circle[value]" value="" size="3" maxlength="128" class="form-text" />
                  Chilometri

                  da
                  <input type="text" id="edit-circle-location" name="circle[location]" value="" size="20" maxlength="128" class="form-text" />

            </fieldset>

I want to set a specific background for the element:
   < fieldset class="openlayers-proximity-filter-exposed form-wrapper" id="edit-circle">
but I cannot find how to tell in the css to apply new style to this one and only this !!
I tried to set attribute to the class:
.openlayers-proximity-filter-exposed .form-wrapper .fieldset but nothing happened ..
Can anybody help me, please?? just tell me how it works when you have to customize classes into div as per this example.
Thank you all!!!!!


texts: Custom field values are not importing with Features

texts:
I would like to export example data(nodes) in feature for others to kick start some reusable module that i developed. The example data contains nodes with custom fields. The problem is that while nodes and default field values(title, body) are importing the values for the custom fields are not. I am new to features. I must be doing something wrong.

For the example data I have selected the nodes, field bases, field instances and rest of the dependencies detected, but this is not export/import the custom field values. I am guess i have to select some more StrongArm variable values since these custom field instances are shared across multiple nodes? if so, how do i detect the dependent variables to particular node instance?...strongarm does not provide any drush command for that purpose...Any help is much appreciated

p.s. Are you using features for exporting/importing Sample Data of you custom module? I may have taken the wrong approach

Features: 7.x-2.0,
uuid_features: 7.x-1.0-alpha3,
strongarm: 7.x-2.0,
Drupal: 7.26


texts: BLOCK_NO_CACHE with Normal page cache enabled

texts:
I'm trying to create a block, which shouldn't get cached, even for anonymous users. But there's "Normal" page caching enabled on the website. As I've read in various places, the BLOCK_NO_CACHE setting doesn't really count for anonymous users when page caching is enabled.

As it stands, it's not an option for me to turn off the page caching, as the website receives moderately high traffic.

I've first tried injecting some HTML with hook_footer but this function doesn't get called as well when page caching is enabled.

The block I'm trying to implement is a very simple one, it only has a bit of text and a link, which upon clicking, sets a cookie on the user's browser (with PHP), and returns the user back to the page where they clicked the link on. Upon returning to the page, the block needs to attempt to read the cookie, and if the cookie is set, the block should no longer be displayed.

However with page caching turned on, if AnonymousUser-A clicks the link and no longer sees the block, then AnonymousUser-B comes to the site, they also don't see the block.

Is there a workaround I can use to get around this issue? As you can see from my use of hook_footer, I'm not heavily inclined to implement this as a block. Any solution that will fit the above purpose is welcome.


texts: Allow a user to sort a list of nodes for the purpose of discovery

texts:
I've got a list of nodes (restaurants) that each have the following fields: name, price, opening hours, location.

I'm looking for a sort module that allows users to input their desired price range, time they'd like to dine, and location and then the nodes will be sorted in order of most relevant to least relevant.

I'm able to do this with filters, but would prefer a ranking system, rather than a filtering one.

Do you know of any modules out there that can help with this?

Cheers!


texts: d8 webform submission views how to exclude Action Apply to Selected Items

texts: The view created using the webform views integration module.. all the fields are shown as desired.  However the CBO box with choices to then apply changes is not wanted. Hoping it's a setting somewhere.


texts:
Would it be safe to say only the files directory should be owned by apache user ?

I have mine set files apache:root

And all other drupal directories root:root ?

My permissions are set to 755 for everything excepting 444 on settings.php

Actually my files I've set to 775 and have
in www chown -R root:apache html

then chown -R apache:root files


texts:
I need to create a link to first submenu item from specific menu. The link will be placed in custom block.

To be more precise, I have a menu with following structure:

parent-menu
 item-1
 item-2
 item-3
 ..

I need that after clicking "parent-menu" user would end up in item-1 page. Also, there will be several links in some blocks, linking to "parent-menu" - they need to open 'item-1' item too.

My current approach is to create 'parent-menu' page template override which finds top child item from 'parent-menu'. That page will be linked from content and main menu.
Problem is that I need a way to find first menu sub item from code.

UPDATE:

Ended up on using query:

$link_path = db_select('menu_links', 'n')
->fields('n', array('link_path'))
->condition('n.plid', '269', '=')
->orderBy('weight', 'ASC')
->range(0, 1)
->execute()
->fetchField();

Is there any alternative way to do this, without querying database?


texts: How to add the admin role to Drupal 7 after upgrading from Drupal 6?

texts:
In Drupal 6 there was a module called Admin Role which allows you to make a superadmin role (same rights as superuser). This function is now in core (as of Drupal 7). So if you install Drupal 7, you get three roles by default: anonymous, authenticated, administrator.

However, when upgrading a site from D6 to D7, this new admin role is missing. How do I add this role or convert an existing custom role to be the admin role?


texts: Form API file upload field default value implementation using AJAX/AHAH

texts:
Apologies for the long explanation.  I have a form built using the From API that is used as a profile for users. It allows users to upload a CV/resume type file for themselves and it is mandatory to upload a file or the user cannot complete the form.

Uploading and saving the files are no problem, but I run into problems when the user tries to update their form.  The file input type in the Form API doesn't have a #default_value option (understandably) which means that when the user comes to edit the form, there are two problems.

The first is that it shows a blank file upload field and the user is expected to upload a file again (as the field is mandatory).  This is confusing for the user and means that more than one file can be assigned to a user.  The second is that the user does not have an option to remove their file and add a new one to replace it.

What I would like to do is write a function that checks to see if the form is being accessed by a logged in user, checks if that user has a file associated with them and displays the field appropriately.  If a file exists, display the name of the file and a link to remove it instead of showing the file upload field.

I could do most of this no problem, but the extra part I would like and can't do is for the "Remove file" link to be an AJAX call that would delete the user's file and then display the file upload field dynamically.  Has anyone done something like this before?


texts: Having my own theme for creating and editing Nodes: No WYSIWYG Editor

texts:
I disabled the option "Use the administration theme when editing or creating content" so I see everything in the default theme.
But now I got a problem: The JS Drupal object is on the bottom of the page (like in a usual page all JS files should be on the bottom).
But CKEditor (which I'm using) needs that object in head.

//update: I checked the scripts and found out, that ckeditor is executed on the very top of all scripts. The Drupal object on the other hand is on the bottom.
I tried to reverse the array, but still the same result. Even jQuery is loaded after CKEditor.

//update2: Okay I changed the order by putting weight on the CKEditor script files and set the scope of every script file to footer, but still the Drupal object is under all files, no matter what weight I give $js['settings']. Maybe that's the wrong item?

Thanks


texts: Entity Reference field using View to Mask Autocomplete with Last Name

texts:
I've posted about this here as well: http://drupal.org/node/1906344

I'm trying to use an Entity Reference field to reference users with a last name field I created on a "Product Page" content type.

You see, whenever you try to reference a user, you're forced to do so with the username. So to get around this, you have to create a view that outputs the last name field from the profile and then use that view in a way that accepts an argument to key off of (i.e. - the last name).

I've created my view and on the views page, this view works. But when I use the "Filter by an entity reference view" to attach my view, I discover that it doesn't work on the node-add page. I'll start typing a last name that's associated with a registered user and, well, nothing comes up. The reference type I indicated in the "Target type" is user and the view isn't anything special: it's just an "Entity Reference" view type set to accept 1 contextual filter (the last name) and subsequently outputs the respective users if that argument matches the last name field value(s). So I don't know what's going on here...

Here's my basic setup:
- Drupal 7.x
- Entity API 7.x-1.0
- Entity Connect 7.x-1.0-beta2
- Entity Reference 7.x-1.0
- Views 7.x-3.5

I'm using Entity Connect to provide the ability to create the user if he or she doesn't exist. Otherwise, the field should reference something--which it currently doesn't.

Any help on this is appreciated and please let me know if you need more information.


texts: importing XML file with drupal 6 nodes to drupal 7

texts:
I am using Views data export module on my drupal 6 website and created a view with data export page, as export file type i've selected XML file.

When I'm downloading .xml file, I can see quotes replaced with &quot; and rest brackets converted in to a code. How can I make them untouched when doing the .xml export?

I am also using feeds module on Drupal 7 website and cannot import that xml file = "There are no new nodes".


texts:
I have a bundle "Text" and bundle "Protocol". The "Protocol" bundle has a field of Entity Reference type which links the "protocol" node with texts that were accepted during that protocol. (I.e. the join is somewhat like "Protocol"->"Text") Also Protocol has following fields: a protocol number (integer) and a date (date-iso)

While viewing "Text"-type node there will be shown information about the corresponding protocol:its number and acceptance date (mention them above).

So the question is: is it a good practice to show this pages via Views? Owing to its Relations feature, obtaining of information related to the corresponding protocol is really easy. But idea itself seems to me being of kinda "bad Drupal way", because there is a standard way of displaying nodes in Drupal.

If the Views is really bad idea, then how should I obtain the protocol's number and date, from tpl.php (or preprocessor function)? Any variants?


texts: Webform no duplicate selections with multiple select lists

texts:
I have a webform (7.x-4) with two selection lists, with the same content, like

A
B
C
D

so I would like to prevent users, who fill out this form, from using the same options in both lists.

i.e., if they check A they should get an error when they check A on the the second list.

what is the best way to do that?


texts: What does the message "hook_flag_access: ignore" mean, and how do I turn it off?

texts:
I currently have the flag module enabled, and I have placed a simple flag on a node content type. The flag works fine, but I'm getting a Drupal message / notification in green that says "hook_flag_access: ignore" when the node is viewed.

It appears to be called by sites/all/modules/flag/tests/flagaccesstest/flagaccesstest.module

What does this message mean, and how can I fix / disable?

I'm using flag 7.x-3.1 on Drupal 7

Thanks,
Steven


texts:
I'm using Nice menus, but it expands children sub menus to right only. I want it so that when you hove on main parent link, it drop-downs a sub-menu with all its children submenus expanded down in a tree.

There's some quality sketch I did as an example:

Doesn't have to be Nice-menus, any alternative modules are welcome. Cheers.


texts: Error guzzlehttp/guzzle ^6.3 -> no matching package found when update from 8.7.9 to 8.8.1

texts:
When i tried to update my project using composer from 8.7.9 to 8.8.1 i get the following error:

Command:

composer update drupal/core --with-dependencies

  [Composer\DependencyResolver\SolverProblemsException]
    Problem 1
        - Installation request for drupal/core 8.8.1 -> satisfiable by drupal/core[8.8.1].
        - drupal/core 8.8.1 requires guzzlehttp/guzzle ^6.3 -> no matching package found.
      Problem 2 .
        - drupal/core 8.8.1 requires guzzlehttp/guzzle ^6.3 -> no matching package found.
        - drupal/ultimate_cron 2.x-dev requires drupal/core ^8.5 -> satisfiable by drupal/core[8.8.1].
        - Installation request for drupal/ultimate_cron ^2.0 -> satisfiable by drupal/ultimate_cron[2.x-dev].

  Potential causes:
     - A typo in the package name .
     - The package is not available in a stable-enough version according to your minimum-stability setting .
       see https://getcomposer.org/doc/04-schema.md#minimum-stability for more details.
     - It's a private package and you forgot to add a custom repository to find it

Any ideas ?


texts: Paragraphs Align Media Left or Right of Text with CSS

texts:
I am using Paragraphs module to create a cutom paragraph. The custom paragraph will have three fields: Image, Text and Position. Would like to use css to align as follows based on the value of the Position field.

Image Left  | Text Right

Text Left | Image Right

Image Top / Text Below

How do I go about doing this? Do I need any extra configuration for the paragraph? Or is all the magic done in CSS?


texts:
I'd like to be able to set the field label as an <h2>. How can I do?

I'm editing the features definition for a field collection directly so if it's possible to set it in there that would be super-handy!


texts: Is it possible for two drupal views to share the same pager limit

texts: I have two separate views 'now' and 'next', they both collectively must only have three items. Is there a way for them to share the same pager limit for example if the 'now' view has one item the 'next' view can only display two items as the pager limit is three.


texts: url of each listed nodes in a view using the content format

texts:
How can I display a node link for each node listed in a view with a content format parameter?

I have set a view with a content format teaser and the template is
 node--article--teaser.html.twig.

<a href="{{ url }}" rel="bookmark"> displays the page link where the view is displayed, not the content.link.

I cannot figure out why it does not work in my site and what could interfere with it.

The only way around I found was to get the node ID with   content.links['#lazy_builder'][1][0].

Do you have any idea?


texts: Get a list of all entity reference fields that reference specific entity types

texts:
Is there a way to get a list of entity reference fields by field type (similar to what is produced by $all_reference_fields = $this->entityFieldManager->getFieldMapByFieldType('entity_reference');) but filtered down to just list the entity reference fields that have target entity types and bundles that match a specified list.

I'm not seeing anything in the entityFieldManager that would make it easy to filter the results of the getFieldMap() or getFieldMapByFieldType() down  to just specific reference fields I'm looking for, because the mapping doesn't contain any of the field's storage information, that contains the list of target bundles and handlers.

Looks like the entity_reference module in core doesn't provide any services that would be the logical place for something like this, so my current thinking is that I'll need to do this in two steps:

Call getFieldMapByFieldType('entity_reference');.
Work through every single entity type in the field map, and call buildFieldStorageDefinitions($entity_type); or something of that nature, to figure out the target entity_type:bundle_name combinations, and track down fields that reference 'taxonomy_term:tag'. This seems horribly inefficient, due to the sheer number of entity_reference type fields in this site, so maybe there is a better way to do this step?

In an ideal world, there'd be just a set of database calls I could make, or even a service in core for entity_reference module! (wishful thinking) ;)


texts: Random order at three-column Slick Slider

texts:
I want to show random content on a slick slider which has three a three column layout (three content elements next to each other) on each slide.

If I set the views' sort criteria to RANDOM it will randomize the slides itself but not the content (the content and order on each slide remain the same).

Is there a way to randomize the content of each slide aswell?


texts:
I'm developing a complaint portal for administration. All complaints are submitted by sites users. I'm fetching these complaints using views and don't know how to add active/Inactive as drop down options in each complaint. As everybody knows complaints' status stays active until it resolves. Active/inactive field is not existed in content type form.

This is for admin ease, admin can change the status of the complaint active or inactive.

Please let know if anyone has any experience regarding this.


texts: Create node with taxonomy field using services in drupal 7

texts:
I am creating node from my android app using services 3. I hit this URL www.mysite/endpoint/node with the following json:

{
    "title": "my act for tax",
    "type": "activity",
    "field_activity_type": [{
        "tid": {
            "tid": "[tid:45]"
        }
    }]
}

field_activity_type is a taxonomy term autocomplete filed.

Node is created successfully but field_activity_type remains empty. I am unable to find a correct way to populate taxonomy field.
Anyone who knows please help me.


texts: Site changes multiple title tags on load

texts: My site is https://www.swiftdigital.com.au. Its built in Drupal 7 and uses Bootstrap 3 theme. The issue is with <title> tag. When I load the site in browser firstly it displays the correct site title that is configured for each page in admin and then after 1-2 seconds it changes the title to "Swift Digital - Contact". I am using Yoast SEO module and it seems like it doesn't have any effect on the <title> tag. I don't know where to debug for the issue.


texts: How can I programmatically deactivate multiple user accounts?

texts:
I have tried the following code, but something doesn't work, could you please help. I need to deactivate several accounts at once, if they satisfy the conditions:

$ids = \Drupal::entityQuery('user')
  ->condition('roles', 'student')
  ->condition('field_school_id', $node_id)
  ->execute();
$users = User::loadMultiple($ids);

$storage_handler = \Drupal::entityTypeManager()->getStorage("user");

foreach($users as $user){
  $entity = $storage_handler->load($user->id());
  $entity->set("status", 0);
  $storage_handler->save($entity); // THE PROBLEM IS IN THIS LINE
}


texts:
I used this tutorial for creating a membership with Drupal Commerce which works well.

How I can set membership expiration?

I know I should use Rules, but I do not know how.


texts: Add class to body depending on role of author of user page

texts:
I need to add a class to the body based on the author of the user profile page. I have two roles on my site: standard and premium. I would like to create a body class to reflect this. So, if I am on a standard member's profile page (regardless of my role) "standard-member" would be added to the body classes. If I am on a premium member's profile page (again, regardless of my role) "premium-member" would be added to the body classes.

Is this something that can be done with the context module?


texts: Views - using "admin/" in path gets me to the home page

texts:
I'm having an issue with the Views module.
Let me say in advance that the site urls have been customized with the module "rename admin path" and the path to the administration section is www.site.com/gestione/ , using www.site.com/admin/ will get me a "page not found" error. I thought this was something worth telling.
I want to make a view which as an administration layout and i have been told this can be achieved but using "admin/" ("gestione/" in my case) inside the path. So i put /gestione/my-archive as URL.

Now if i try to access the page i see the administration home page instead of the view. If i don't put any prefix (so that the url is www.site.com/my-archive) it works, but it has the normal front end layout, i have tried:

"gestione/content/my-archive" brings me to the content section of the administration menu
Any variation like "gestione/test/my-archive" still gets me to the administration home (likewise "gestione/content/test/my-archive" brings me to the content section)
Giving no access restriction
Anything that doesn't start with "gestione" will get me to the view but with front end layout
using "admin/" will give me a page not found error
Rebuilding the menu calling menu_rebuild();
Deleting the caches

EDIT: disabling the "rename admin path" and using /admin/my-archive did the job, but i wonder if there's any way to keep it working


texts: How do I find "where-used" / many-to-one related entities?

texts:
A field in my Content Type A references a Content Type B.

I'd like to find, in each instance of Content Type B, a list of all the As that reference it at a particular point in time.

[Update]:
I made the question less ambiguous in the light of the answer I found with help from others here.


texts: I use Contact and Locale modules. I wanted to change text included in e-mail so I went to modules/contact/contact.module and I replaced appropriate lines. Unfortunately, that text is not translate to my national language (of course is understanding). How can I add translation to new-added text?


texts: Using git over ssh from localhost to my Shared Hosting

texts:
I managed to install smoothly git and drush on my Shared Hosting. Cool.
Now I created there a git repository:

$cd public_html/drupal
$drush dl drupal
$git init
$git add .
$git commit -a -m "My Project"

A .git folder has been created

Now all I am trying to do is to clone my remotely Drupal installation on my local computers home or whatever:

git clone ssh://username@*.*.*.*:portnumber/public_html/drupal

it connects well I enter the password but then I got the message:
fatal: /public_html/drupal does not appear to be a git repository
fatal: The remote end hung up unexpectedly

What did I do wrong? All I need is to use git (somehow as svn) as versioning. I don't need to post the project on github as it is a private one.

Help appreciated


texts: Is there any module to create a set of field without creating new entity field for each one?

texts:
My objective is to have a module which gives me the option to create a entity field that can have multiple field values.

For example, the location module. It creates an entity field of type 'location' which can have a set of field values (country, province, city, address, etc.). In the database this module creates a table 'location' which stores all these values with a key 'lid'. The main entity field has a  'lid' value to connect with the set of values. And we are able to used tokens for all these field values.

I have tried Field Collection, Multifiefld, Composed Field modules, but none of those actually do this.


texts: Make phone field required if certain shipping method is selected

texts:
I use drupal 6 and ubercart 2. My aim is to make phone field in delivery address required if certain shipping method is selected. I have set up a jquery script that shows a message to the user saying that phone is needed after customer selects the shipping method. Despite of this, some customers don't fill out the phone field.
I would like to add a non js check after submission of checkout page.
I suppose I would need to write a small module. A need help with the start of the code

<?php
IF
{[mymethod] = true}
then {
  $form['panes']['delivery']['delivery_phone']['#required'] = true;
}
?>

Thank you very much.

EDIT: according to @Adam Balsam answer I tried to make custom module
This is uc_checkout_phone.module

<?php
function uc_checkout_phone_uc_cart_checkout_form_alter(&$form, &$form_state) {
  $form['panes']['delivery']['delivery_phone']['#element_validate'] = array('uc_checkout_phone_phone_validate');
}
function uc_checkout_phone_phone_validate($element, &$form_state) {
  if (($form_state['panes']['shipping']['shipping_method']['#value'] == 'Doprava - kurier DPD') && ($element['#value'] == '')) {
   form_error($element, t('You must enter a phone number if you select XXX as a shipping method.'));
 dpm($form_state); }
}
?>

This is uc_checkout_phone.info

name = uc_checkout_phone
description = phone required
core = 6.x

The form id should be uc-cart-checkout-form. I had to write it using underscores. The shipping method is Doprava - kuriér DPD, I tried also the value which is flatrate_3---0 but I get no warning message if I let the phone number empty. Where can be the problem?
I named themodule: uc_checkout_phone


texts: Can I include a list of sub-menu pages in the content of the parent page?

texts:
I have a page that is the parent of a series of menu items, e.g. Projects, with some project pages as child items in that menu. I would like this parent page to automatically have the list of children in the content. Is this possible?

I have a block that I created that lists this menu via the Views module...if there is a way to use that, it might be an alternative.

Thanks


texts:
I'm rebuilding (after Drupalgeddon) and I have a table that's gone missing... somehow.

It's being used to build Views displays for the homepage and so the homepage isn't loading at all. Which is obviously undesirable...

Error:

PDOException: SQLSTATE[42S02]: Base table or view not found:
1146 Table 'drupal.field_data_field_brief_summary' doesn't
exist:
SELECT t.* FROM {field_data_field_brief_summary} t
WHERE
(entity_type = :db_condition_placeholder_0)
AND (entity_id IN (:db_condition_placeholder_1,
:db_condition_placeholder_2, :db_condition_placeholder_3))
AND (language IN (:db_condition_placeholder_4))
AND (deleted = :db_condition_placeholder_5)
ORDER BY delta ASC; Array (
[:db_condition_placeholder_0] => node
[:db_condition_placeholder_1] => 1026
[:db_condition_placeholder_2] => 1051
[:db_condition_placeholder_3] => 1095
[:db_condition_placeholder_4] => und
[:db_condition_placeholder_5] => 0 )
in field_sql_storage_field_storage_load()
(line 392 of C:\projects\drupal\modules\field
\modules\field_sql_storage\field_sql_storage.module).

I used the Drush field listing function as described here Is there a listing of Drupal fields? or more specifically, the drush field-info fields command in the comment below the chosen answer. Which displays, amongst many others:

field_brief_summary    text_long

So I think it's there. But the tables field_data_field_brief_summary and field_revision_field_brief_summary are clearly not in the database when I check.

What does on do in this situation? I need field_data_field_brief_summary (and version) back, and I have a copy of it in the version I'm using to rebuild from, but it should be there and I'm wary of trusting that I can just use a MySQL statement to CREATE and INSERT INTO when it's something implicit in the Drupal CMS.


texts: How to control Block revisions before being published?

texts:
Does Drupal support blocks versioning? Are there any modules can be used for controlling blocks revisions and publish selected version?

For example: a newly created blocks shall be published after being reviewed by a reviewer role user. So that the content will not be displayed in the page until it is published, meanwhile the content can be edited and sent for review and publish many times between the creator and reviewer.

Any suggestions about how to achieve this?


texts: is using non English words for paths recommended?

texts: I'm working on a Drupal site which has a non-english language.I want to change the paths to something better than node/[nid].Nodes also have a non-english title and I want to set the path to content/[node-title].does it cause any problem?does it affect on SEO?


texts:
How can I display a view's count in a navigation item?

I have a view the displays a list of stories (a content type) and I have an item in a menu that links to that view. I need to display the number of items returned by that view next to the menu item that links to it on all pages of the site.

The solutions I've thought of so far have been:

Add a block to the view and have that blocked displayed in a hidden area on all pages and then use the total_rows or num_rows property of the view's object. The disadvantage of this is that this view then runs on every page possibly causing performance issues.
Add a block (or some other type) to the view that calculates the count and have that displayed by the menu item some how. But I haven't been able to figure out how to do this. I tried using the "Use aggregation" setting but I get a "broken/missing handler" error when using an "Aggregation type" other than "Group results together" in Sort or Filter criteria.

Any help with this would be much appreciated.

This is running on Drupal 7.7.


texts: How add/update a record conditionally based on existence of primary key?

texts:
I have a table with structure:

Table
(
record_1 int,
record_2 int,
PRIMARY KEY (record_1)
);

I want to write/update a record based on its existence.

I was told to use drupal_write_record(), but for that I must know if the record already exists or not.

In my case I am not aware of its existence.

How can I do this?


texts: How do I override /theme/custom twig in my module to render input fields?

texts:
I have a module that is building a form. I want to theme the form using twig within my module so it does not interfere with my theme/custom twigs.

My buildForm function is:

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

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Name'),
    '#title_display' => 'invisible',
    '#required' => TRUE,
  );

  $form['#theme'] = 'custom_form';

  return $form;
}

I have set the theme for the form as custom_form and it works fine using this in my .module file:

function custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'custom_form' => array(
      'render element' => 'form',
    ),
    'input' => array(
      'template' => 'input',
      'render element' => 'element',
    ),
  );
}

However the input fields are still being rendered using input.html.twig file in my /theme/custom theme folder.

I have created copied the twig template file using the same name and placed it in my custom_module folder however Drupal is still using my theme input.html.twig file.

How do I override this twig and use the input.html.twig file in my custom_module templates folder?

Thanks


texts:
I want to allow one more tag in Filter html Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
<blockquote>.

I want to add <table> in this list. How can I edit this and in which hook I can modify this.

Anyone can help me?


texts: How to use flags to pass variables to users?

texts:
Backstory:
Ok, I have a site where users can post events, rate them, attend them (everyone can see who will attent) and such. Now I want to make it so you can add variables to users, which resembled what they did. for instance: User: Anon had a red jacket and was drunk.

Then I would like a list that is unique PER event with these variables which the users can add to their own profiles. (so everyone can see what they did/had at that specific event)

for instance:
List of events:
Color run, Jumping, Racing
"User goes to event "color run"
and there is a list with:
"what resembles you at this event:
-Drunk
-In a group
-Red jacket"

Then they select "drunk and red jacket" and submit/bookmark.

Now I want this to be saved to their profile so when they go to their own profile it will look like this:

profile>events>color run>

red jacket
drunk

and for a different event it could be that they chose something else and that would show up.
Any ideas how to make this reality?

I was thinking about using blocks but I have no clue how to make the multiple select part.


texts:
I am migrating a CSV into D8 node type which has a double field. The CSV has the following structure:

I am trying to migrate the year, from the header, into the first double-field subfield (as a label) and the population data for each country (Afganistan, in the example above) into the second double-field subfield.

The double-field has the following interface (the data in this example was entered manually):

And, this is how the data is represented in the node as seen via Devel:

I have tried a variety of things in my migration yaml code but I have not been able to migrate either the year nor population data. My code is below:

.
.
.
process:
  type:
    plugin: default_value
    default_value: census
  title: 'Country Name'
  field_country_code: 'Country Code'
  field_count_first:
    0:
      plugin: get
      source:
        - 1960
.
.
.
------- also - tried -----------
.
.
.
process:
  type:
    plugin: default_value
    default_value: census
  title: 'Country Name'
  field_country_code: 'Country Code'
  field_count:
    first:
      0:
        plugin: get
        source:
          - 1960
.
.
.

I would appreciate some help.


texts: Sending form to mail from custom module fails without error

texts:
I've created a module with a form and a block.
When I push the subscribe button, the submitForm function is executed.
The successmessage is shown, but no e-mail is send ...
There are no errors reported in the recent logmessages or in on the server in the folder /logs.
public function submitForm(array &$form, FormStateInterface $form_state)
    {
        /**
         * @var MailManager $mailer
         */
        $mailer = \Drupal::service('plugin.manager.mail');

        $email = $form_state->getValue('email');
        $params['context']['subject'] = "Subscribe newsletter";
        $params['context']['message'] = 'Someone subscribed: ' . $email;
        $params['email'] = $email;

        try {
            $response = $mailer->mail('my_module', 'subscribe', 'to@email.com', 'nl', $params);
            if ($response) {
                $this->messenger()->addStatus($this->t('You are successfully subscribed to our newsletter with your e-mail: @email', ['@email' => $email]));
            } else {
                $this->messenger()->addStatus($this->t('There was an error.'));
            }
        } catch (MailHandlerException $e) {
            \Drupal::logger('mailinglist_send_mail_error')->notice('
' . print_r($e, true) . '
');
        }

    }


texts: How to remove extra white spaces and line breaks from HTML in drupal 7

texts:
I am using drupal 7 and created my custom theme. Now I am facing problem that page is containing extra line breaks and while spaces when I open view source.

Can some one suggest any module/code snippet which minimize my html so that page render fast.

Else tell me where I can minimize it in my template.php file or any .tpl file.


texts:
I want to display in my page.tpl.php 3 custom fields form the latest content type added to my website.

I have a custom content type called "Articles" with three custom fields, field_1, field_2, field_3.

How can I display on every page of my website those three fields from the latest content added to "articles"?
I want to do this without using views.


texts: Why doesn't drupal_render work, but render does?

texts:
I've a piece of code what is rendering a custom table (see var_dump below) what is shown on for specific states of the node. The data of the table is for both states the same.

array(1) {
  [0]=>
  array(5) {
    ["#theme"]=>
    string(5) "table"
    ["#header"]=>
    array(2) {
      [0]=>
      string(4) "test"
      [1]=>
      string(9) "geen test"
    }
    ["#rows"]=>
    array(2) {
      [0]=>
      array(2) {
        [1]=>
        string(6) "e1a1r1"
        [2]=>
        string(6) "e1a2r1"
      }
      [1]=>
      array(2) {
        [1]=>
        string(6) "e1a1r2"
        [2]=>
        string(6) "e1a2r2"
      }
    }
    ["#prefix"]=>
    string(38) "
Table
"
    ["#attributes"]=>
    array(1) {
      ["class"]=>
      array(1) {
        [0]=>
        string(15) "previous-scheme"
      }
    }
  }
}

The custom states of the node are determined by a condition what prints one of the following gathered variables.

For the variable at the line below works with both drupal_render and render.

$kickoff_deadline .= '
Between kickoff and deadline
'.drupal_render($table);

For the variable at the line below only works with render, without it wont show anything.

$after_deadline .= '
After the deadline
'.render($table);

So what is happening? Why doesn't drupal_render work for a similar printed variable what does work?


texts: How do I get a view to list nodes that have the same detail in a particular field as the current node?

texts:
Using D8, I'm putting together a genealogy site for my family and having a hard time creating a block that lists the brothers and sisters of the Person being displayed.
The basic unit of the site is the content type, "Person". Each Person node has their first and last name and date of birth.
After much deliberation, I settled on defining relationships between people with a content type called "Relationship" that has two fields, Person A and Person B (both drawn from existing Person nodes), and a taxonomy tag to define how they are related (Mother, Father, Spouse, etc.). To aid in having some predictable logic, I've decided that parents will always be Person A and children will be Person B.
I started down the road of defining sibling relationships explicitly with a "Sibling" tag on a Relationship node (Ann is Bob's sibling, Ann is Claire's sibling, etc.), but for families with many siblings, that creates a need to create definitions for every sibling match variation (Bob is Claire's sibling). To simplify things, I'd like to use the logic that all people with the same mother are siblings (the real world introduces other complications, but I'm trying to handle the most basic scenario first).
I've set up a View, based on the Relationship content type, with a Block display and an EVA display. The EVA display is attached to the Person content type. I've selected "Use the ID of the entity the view is attached to" to "populate the view's arguments."
I've set one Filter Criteria to dictate that "Field Relationship = 'Mother'". I'm trying to set another Filter Criteria to use the logic of "Field Person A is the same as that on the Relationship node where Field Person B is ID (as taken from current node)." The list would then display all the Person B names that had the same Person A. (To not list the person whose node was currently being displayed, I could then add a filter to exclude the Relationship node where Person B is ID [as taken from current node].)
I've turned on the modules, Token and Token in Views Filter Criteria. Not surprisingly, this does not reveal a token for "Person A from Relationship node where Person B is ID(as taken from current node)."
How do I get this block to recognize and filter based on "Field Person A is the same as the Person A on the Relationship node where Field Person B is the Person being currently viewed?" Screen shot of current settings attached.
Thanks in advance!


texts:
I'm learning about the Entity API. I have a simple extra table that I'd like to "drupalize" so that I can use it in Views, for example.

I've read quite a bit, watched a few videos, looked at quite a few examples. I'm stuck on the concept of bundles. I understand what bundles are (e.g. node types are bundles of the node entity).

But for my use there will only ever be one bundle. In the examples I've seen the bundle is stored in the database table; this is not necessary for me as it would be the same value stored against every record. So I was thinking I could somehow skip this, or have my entity always return a standard string for bundle.

Have I misunderstood? Do bundles always have to be implemented, and implemented at database table level?


texts: UI.selectmenu from jQuery is not imported!

texts:
I have this function to add libraries from jQuery UI, but the selectmen, and tooltip seems to be missing! anyone know how to import them in Drupal 7.4?

function kalender_init() {
    $lib= array(
        'drupal.ajax', 'drupal.form',
        'drupal.autocomplete',
        'jquery', 'ui','ui.selectable',
        'ui.droppable','ui.draggable',
        'ui.sortable','ui.resizable',
        'ui.tabs','ui.dialog',
        'ui.datepicker','ui.autocomplete',
        'ui.button', 'ui.buttonset',
        'ui.selectmenu', 'ui.tooltip',
        'form'
    );
    foreach($lib as $l){
        drupal_add_library('system', $l);
    }
}

I need for the form over here:

foreach($result as $color){
    array_push($colors, $color->name);
}
foreach($colors as $color => $id){
    array_push($attr, array('class' => array('colors-list'), 'data-color' => $color) );
}
$form['gruppen']['checkbox'][$group->id]['color'] = array(
    '#type' => 'select',
    '#suffix' => '

',
    '#default_value' => 0,
    '#options' => $colors,
    '#options_attributes' => $attr,
);


texts: Drupal Validation Function Not Being Called

texts:
So I have a content type I am trying to add a validation function to.

function ocomp_source_type_form_alter($form, &$form_state, $form_id) {
  if ($form_id == 'source_node_form') {
    array_unshift($form['#validate'], 'ocomp_source_type_form_validate');
  }
}
function ocomp_source_type_form_validate($form, &$form_state) {
    drupal_set_message("Validate function entered");
}

It is the first validation function being run:

#validate (Array, 2 elements)
0 (String, 31 characters ) ocomp_source_type_form_validate | (Callback) ocomp_source_type_form_validate();
1 (String, 18 characters ) node_form_validate | (Callback) node_form_validate();

I've tried everything I could and I still can't figure out why this validation function isn't being called.


texts: How do I add typekit fonts to a D8 theme?

texts:
Having looked over the existing D8 documentation on adding JS to the <head> of a page, I'm still not sure how to go about it?

What is the correct way to achieve this on every page for my theme:

<script src="//use.typekit.net/abc0abc.js"></script>
<script>try{Typekit.load();}catch(e){}</script>

Regarding inline JS, from the latest D8 documentation:

  In the case of front-end/styling (e.g. hosted font services), the JS
  belongs in the theme. Put the JS directly in your html.html.twig file.
  In the case of fonts, this will also allow you to put it right in the
  place that gives you the best (and fastest) end user experience,
  because it allows you to prevent a FOUT (Flash Of Unstyled Text) while
  the font is still loading (fonts loaded through JS must be listed in
  the HTML  before the CSS)!

So, I guess the inline JS goes directly into html.html.twig, but what about the external file?

I have this in my theme files, but it's not adding the external file to any pages:

mytheme.info.yml

libraries:
  - mytheme/typekit

mytheme.libraries.yml

typekit:
  version: 1.x
  js:
    //use.typekit.net/abc1abc.js: { type: external }


texts:
So I am recently started working on front-end development, and have started messing around with making my own custom templates for modules. I have been able to get page related templates to work, but am having a problem getting form related templates to work.

This is for Drupal 7.

I have a form, like this (Its not quite this basic, but very similar and no special fields)

function mymodule_menu() {
  $items['admin/atavism/config'] = array(
    'title' => 'Configuration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('atavism_config'),
    'access arguments' => TRUE,
  );
}

function atavism_config() {
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save Configuration',
  );

  $form = theme('atavism_config_form', array('form',$form));
  return $form;
}

function atavism_theme() {
  return array(
    'atavism_config_form' => array(
      'template' => 'page--atavism-config-form',
      'path' => drupal_get_path('module','atavism') . '/theme',
    ),
  );
}

And then I created the page--atavism-config-form.tpl.php. Inside of the form, I am using;

print render($form);

I am doing the same thing for pages that are just content (normal pages with just text and markup for example, and no forms), and it's working as intended, but I am also doing the same thing for a couple of different forms I have, and I am running into two problems. Either #1, the form renders in the template, but ONLY the provided $form variables are available (so the form can't be submitted), or I get a white screen with a PHP error of 'Unsupported operand'.

It appears I may be doing something wrong with forms, but I can't figure out what. Could somebody please help me?


texts: How to convert user menu tabs to menu links?

texts:
I have on user account 5-6 tabs created by some modules.My wish is to covert these tabs to menu items so as to insert to 2 separate menu links.
I have read that something like that could be possible with hook_menu_alter.
Is this correct?If so,how can I use it in my case?
thanks a lot


texts: Drupal 7 Views Contextual Links edit Nodes and Fields

texts:
I created some Views with Drupal 7 and also installed the module Contextual Links. It helps me to edit Views and Blocks. But for non-admin users like Editors etc. it would be great to even edit Nodes or Fields with Contextual Links.

So I hover a Field there should appear a Edit Link.

I couldn't find any detailed settings for Contextual Links.

Please tell me how to set this up.


texts:
I don't fully understand how the rate module integrates with rules.

Here's my situation:

1) I created a widget of the type: Number up / down widget which allow users to vote in nodes of the Answer content type.

2) I created a rule which is fired in the event: User votes on a Node with the condition "Check the value of the vote" is "1"

3) A user "vote up" an Answer and the rule is fired.

So far so good...

The problem:

4) The same user "vote up" the same Answer and the vote is not added because the user only can give just one "vote up" per node, this is how the rate module works and it is all right. The problem is that the rule is fired even when the vote is not added, this is wrong, the rule should be fired only if the node get the vote.

Is this a bug? Do I have to add other condition to the rule?


texts: Pager information in services_views json response

texts:
Is there a suggested mechanism for retrieving pagination/pager information in a JSON response in a services_views configuration? I thought enabling the pager would give me something, but it does not. The only way seems to be for me to hard-code the pagination into the module, which seems very unsustainable.

Is there a more preferred solution for for ajax calls that need to know the total number of results in the view?

Below is what I've got so far (patch against services_views.resource.inc):

---- sites/all/modules/contrib/services_views/services_views.resource.inc -----
index 9aeeb1b..24b948f 100755
@@ -27,6 +27,10 @@
  */
 function services_views_retrieve($view_name, $display_id = 'default', $args = array(), $offset = 0, $limit = 10, $return_type = FALSE, $filters = array()) {
   $result = array();
+
+  // Added by SR 201212031623
+  $total_rows = _get_view_total_rows($view_name, $display_id, $args, $filters);
+
   $view = views_get_view($view_name);

   // Put all arguments and filters and then execute.
@@ -70,6 +74,10 @@ function services_views_retrieve($view_name, $display_id = 'default', $args = ar
       $items = array();
       foreach ($view->result as $row) {
         $item = new stdClass();
+
+        // Added by SR 201212031623
+        _set_total_rows(&$item, $total_rows);
+
         foreach ($view->field as $field_id => $field) {
           if (!empty($field->options['label'])) {
             $field_label = strtolower($field->options['label']);
@@ -177,3 +185,34 @@ function services_views_execute_view($view_info, $view = NULL, $display_id = NUL
   $view->destroy();
   return $output;
 }
+
+
+
+/**
+ * Get the total number of results prior to applying offset
+ *   Added by SR 201212031623
+ */
+function _get_view_total_rows($view_name, $display_id, $args, $filters) {
+  // Statistics and counts
+
+  $view_stat = views_get_view($view_name);
+  $view_stat->set_display($display_id);
+  $view_stat->set_arguments($args, FALSE);
+  $view_stat->set_exposed_input($filters);
+  $view_stat->pre_execute();
+  $view_stat->execute();
+  $total_rows = $view_stat->total_rows;
+
+  return $total_rows;
+
+}
+
+/**
+ * Set the total number of results into the items object
+ *   Added by SR 201212031623
+ */
+function _set_total_rows(&$item, $total_rows) {
+  // Add stats into each row if requested
+  $total_rows_label = "_total_rows";
+  $item->$total_rows_label = $total_rows;
+}


texts:
I just enabled the Subdomain module but when I go to the subdomain url as a anonymous user I get this message:

Access denied
You are not authorized to access this page.

Update: I tried giving the anonymous visitor all permissions and the page showed. Now I started to disable permissions one by one till I found out which permission makes it possible for me to see the page and not get the acces denied message.
The permission I need to have enabled to get this to work is: Administer site configuration. Of course it's not possible to leave it like this...but maybe someone now knows what the problem could be.
Any suggestion on how to solve this or other things I can try?
Thanks


texts: Unable to get CKEditor to work using Drupal 7

texts:
I've installed the Wysiwyg module for Drupal 7, as well as the latest CKEditor, configured the settings, and yet it refuses to appear! I've gotten other editors to work but they're not as good.

I'm the only one using the site so I don't have to configure permissions right?

I would have thought this would be one of the simpler things to do in Drupal!

Any help greatly appreciated.


texts: Which preprocess hook do I use to fire some HTML altering PHP?

texts:
I have some PHP that ultimately says 'If this class is present in the HTML, add this string to the $additional_classes array'. Eg, something similar to:

$leftcol_empty = empty($content['leftcol']);
$additional_classes = !$leftcol_empty ? 'medium-8 medium-pull-4' : '';

Currently, I've put this at the top of my .tpl file and it works fine. However, I've been told I should move it to the 'theme preprocess function'.

I looked through my theme's template.php file and tried adding it to my_theme_preprocess_page, my_theme_theme and my_theme_process_html but it stopped working.

I've tried Googling for theme preprocesses but haven't found anything that works.

Would anyone know what preprocesses function I can use here?


texts: When is the available 'language: English French...' link displayed under translatable content?

texts:
I am struggling with the i18n configuration of my site and the display of the available translated content 'languages' link displayed next/under the content.

Under which condition will this link be displayed for translated content?

The content type is translated-enabled
The language field must be displayed/visible in the content type configuration
There must be more than one language made available
The content must be translated
...?

I guess all the above apply, but is there more?

The reason I am asking this is because I believe I have configured my site properly, but I still don't see that link to jump between translated content. I am looking for a check list to find my error(s) or misunderstanding. Thanks.


texts: How can we achieve the multi recipient shopping cart using ubercart

texts:
With Ubercart we want to develop a multi recipient eCommerce site.

Is there any free open source tool that can achieve this? What method can be used to construct multi recipient functionality.


texts: How do you create a block of fields to a second Profile2 using views?

texts: I can create a list of profiles of a specific type. That works great. But what's stumping me is I need a view that has fields that pertain to a specific person. Say for instance you are on Bob's "personal" profile and there is a block that has information for bob's second "business" profile (or any other member's other profiles for that matter). How do I create a block for this profile with relative fields that only populates on demand?....


texts:
I'm using the Auction module now. The Auction works fine, but there are no emails sent to users when they place a bid. When you insert your bid

  Unable to send e-mail. Contact the site administrator if the problem persists.

When I create an account, then i get a email with instructions. Only by the Auction module the mails will not sent. I saw one topic:

Drupal node 1945662

But there was no good answer for me. I used this module auction


texts:
First things first: happy 2015 to everybody. :-)

Now, I am quite new with Drupal distributions and profiles and here is my situation: I have a running site where I have contributed modules and custom modules. I've installed profiler builder module. When I use drush distro to create a distribution, it generates 2 make files: drupal-org.make and local.make.example. The last one "contains" the first one and it contains the custom modules as well.

When I run drush make local.make.example ./destfolder, it throws some errors. It says "non-existent project type on custom-module". So after a bit of research I've been able to make it work adding some information to the local.make.example, and adding the custom modules in a zip format.

My question is, why does drush distro generates a useless folder structure (i.e. modules, themes, libraries)? Am I able to put something there to make drush-make work on local.make.example without needing to add extra information? Am I missing something?

The extra lines of code I added in each custom module to the local.make.example was:

projects[custom_module_name][type] = "module"
projects[custom_module_name][download][type] = "file"
projects[custom_module_name][download][url] = localurl

Thanks very much for your time and let me know if you need further information.

EDIT

I'm going a bit crazy about this… I've just found out that drush make creates the custom modules' folders but they are empty. Nothing inside… So basically, I just don't know how to tell drush-make to build the initial drupal folder's architecture when custom modules are stored on the same computer I'm executing drupal-make…

I've seen most of the examples that evolves custom modules use git, but I'd just like to know how to make it work with custom modules stored on my machine, if possible.


texts: How do exposed views filters make their queries URL safe?

texts:
I'm creating my own search form in D7, and I need to sanitize the search text so that it is URL safe. I need to mimic the way that the views module does it because I'm using the search_api module and views.

In short, I need to make this:

"what is going on around here, anyway?"

look like this:

what+is+going+on+around+here%2C+anyway%3F

How do I do that?


texts:
I am using a view to show content with the name of the node as an exposed filter. None of the operators suites me and I was wondering if I can manage to use Regular Expression Operator for the desired result.

What I want is very similar to "Starts With" operator but the difference I would like to search for EVERY word that Starts with the given value and not the start of the sentence.

Is this possible with Regular Expression operator? What is the actual Regular Expression for that?

Thanks


texts: Shipping line items not displaying with [commerce-order:line-items]

texts:
I have Commerce and Shipping and Flat Rate installed and working correctly. Shipping is added to an Order and charged to the customer.

But when I go to display the shipping line items, e.g. in a order receipt email, they are missing.

My Rule uses this:

Order Details:
[commerce-order:commerce_line_items]

Total Price: [commerce-order:commerce_order_total]

This correctly displays each product line item, and the order total, including shipping line items, but does not display the shipping line items.

I read about a filter in the View at admin/structure/views/view/commerce_line_item_table/edit/default and I see that it is set to only display product line items. But I don't want to mess with that View unless I know what I am doing.

Can I Add a new View display? If so, which kind (Data export?) How to call that display in my Rule?

Thank you.


texts: How do I render user Login block in main menu?

texts:
I wrote the following code but I see only 'array' word.

function mytheme_menu_tree__primary(&$variables) {
   return '
' . $variables['tree'] . module_invoke('user', 'block_view', 'login')['content']
    . '
';

}


texts: Download true file name instead of from drupal version changed filename

texts:
i have some file upload fields which works great. the file is stored on public file system and will be able to get downloaded from the users (in a specific node).

the issue is when i update the file (pdf) with a new version in the same month, drupal renames the file and save a new instance instead of updating the file (i know the reasons, avoiding global file conflicts on the page).

the user will download the renamed file which is wrong (e.g. manual_1.pdf).
how can i change the filename into the name that is in its metadata (manual.pdf).

is there any hook, module or settings?


texts:
I'm attempting to perform a query on webform submissions so I can display all submissions submitted by a specific user. However I'm not sure how to make this query. I made a guess that webform submissions were nodes themselves and performed a query like this

    $query = \Drupal::entityQuery('node')
        ->condition('type', 'webform');
    $nids = $query->execute();
    die(print_r($nids));

But it produced no results. Is there a way I can perform a query on webform submissions so that I can select all submissions authored by a specific user?

UPDATE: Looking through the webform module, I did see some code querying submissions.

$query = $this->getQuery();
$query->condition('webform_id', $webform->id());
$query->condition('in_draft', FALSE);
$query->range(0, 1);

This is exactly the kind of query I want to perform but when I try to use getQuery() I get

  Call to undefined function Drupal\my_module\my_helper_class\getQuery()

I understand how to start entity queries for nodes like this

 \Drupal::entityQuery('node')

But is there a way to start an entity query without specifying the entity type? Or is there a way to find out what kind of entity type webform queries are?


texts: How to correct my Rules Components to perform VBO operations to add or remove a role for the Group module?

texts:
I followed the instructions included in the answer to the question "How to implement the mass operations on the Group's members page using Views?". The 2 Rules Components in it (to either block or unblock a member), work fine (and my VBO view shows the mass operations that use those 2 Rules Components).

Now I want to create similar Rules Components for some of the other typical mass update operations, related to members and/or roles (as used in the context of the Group module).

Below are the 2 Rules Components (in Rules export format) I created for this so far:

1. Add a role to the selected members:

{ "rules_add_role_a_group_membership" : {
    "LABEL" : "Add role a group membership",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "group_mbrship" : { "label" : "Group membership", "type" : "group_membership" } },
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ]
  }
}

This Rules Component should implement the equivalent of the Update option "Add role to selected members" (as shown on group/gid/member, with gid=group id).

2. Delete the role of the selected members:

{ "rules_remove_role_a_group_membership" : {
    "LABEL" : "Remove role a group membership",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "group_mbrship" : { "label" : "Group membership", "type" : "group_membership" } },
    "IF" : [
      { "data_is" : {
          "data" : [ "group-mbrship:roles" ],
          "value" : { "value" : { "group_admin" : "group_admin" } }
        }
      }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "group-mbrship:roles" ], "value" : { "value" : [] } } }
    ]
  }
}

This Rules Component should implement the equivalent of the Update option "Remove role from selected members" (as shown on group/gid/member, with gid=group id).

When I add or remove a role, the following error displays :

I have a problem with the confirmation of action display :


texts: Hi everyone I was wondering if it's possible to have directories of files attached to an organic group so that only group members and admins can access those files. If so whats the easiest way to accomplish this? I tried to use a htaccess file in files/private/groups (the directory I want to store these files in) but to no avail.


texts: Prefixed node path aliases with arguments in menu

texts:
I already have code that will take a path such as www.example.com/site/123/campaign/456/mynodealias. It loads the aliased node with extra arguments, site and campaign, which could change at any time and could be potentially thousands of them.

I now need to display a menu that links to paths like the above. For example, let's say I start on the path www.example.com/site/123/campaign/456, and I have two nodes (mynodealias1, and mynodealias2). I would need a menu with links to my custom paths:

www.example.com/site/123/campaign/456/mynodealias1
www.example.com/site/123/campaign/456/mynodealias2

Do you have any suggestion about the best way to go about this?


texts:
I'm having trouble understanding how to approach layout in Drupal. I want to create a structure where (authorized) users with no designing skills can add content by simply adding content selecting a particular content type.

So e.g. I want to have one type of page that consists of a number of sections (rows) with an image on one side (should be possible to alternate which side) and a heading and text on the other side. If the heading and text is on the right, the heading should be just above the text, and not above the image to the left.

An arbitrary number of sections/rows should be possible to add.

I've managed to do something like this with panels and mini-panels. But it seems like I'm trying very hard to achieve something that feels rather basic... In any case, what I did was I added a page selecting panels with the 1-column layout. This allows me to add rows arbitrarily. First problem here is, the end user would have to select this on their own, I would have liked to have a preset content type with this.

Secondly, I created some mini-panels with content that can be added to the sections of the panel page. More problems: to create these mini-panels and make them lay out as described I have to create mini-panels of a 2-column format, omit the title, add only an image to one of the columns using add custom content selection - no title, and add a title and some text to the other column.

All of this is rather complex just to achieve this layout. It makes me think it would be much easier to just use a wysiwyg editor and lay it all out manually instead. But that is just what I'm trying to avoid. End users would come up with all kinds of layouts, creating a site that does not have a structured feel at all...

Previously I have only done sites in php and CodeIgniter framework, where I naturally have full control and can just add the divs I want, using something like 960 or blueprint to help with layouts, and style it individually with css. But that is dependent on doing it all yourself or at least with only others who know at least some web design. I don't know if modules based on 960 or something like that would help, since I need to be able to add sections etc arbitrarily? All I've seen for this is panels, but maybe I'm wrong?

So how do you approach this in Drupal? Any help will be greatly appreciated, because I'm really having a hard time understanding the basic thinking of layout in Drupal...

Edit:

this is a good example of the type of layout I'm referring: http://www.teamworkpm.net/features


texts: Retrieve Webform submission data from database

texts:
Here's a little background on my project: I have 10 or so webforms let's call them Forms A thru J which are for different departments of a college.  I also, have 1 credit card processing form let's call Form Z.  I will be collecting information from a form like Form A specific to that departments needs and upon submission will redirect the user to Form Z to process a credit card transaction.  I have created a webform handler to redirect the user from Forms A-J to Form Z and a handler to process the credit card transaction.  In the redirect handler I am able to pass all of the information from Forms A-J to Form Z using the query string in the URL.  I want to avoid this since there would be Personal Identifiable Information (PII) being passed through the URL.
I want to be able to retrieve the data submitted on say Form A from the database when Form Z is loading.  I should be able to pass the webform node ID and submission ID to Form Z through the URL query string and use them to get the data from the database.  I found these posts which give me an idea of how to retrieve the data from the database:
Programmatically update Webform Submission by sid
Load webform submission
https://www.drupal.org/project/webform/issues/2911356
What I can't find is how do I get this to run when Form Z is loading.  I've seen a couple of posts on hook_form_alter but those posts are using it in a different way from what I am trying to do so I don't know it that's the way I need to go.
Once I retrieve the data from the database I need to populate that data into I'm thinking some hidden webform fields on Form Z.  I'd like to be able to fill billing address with the address submitted with the previous form upon request (checkbox or button).  Also, I need to be able to have the data from the previous form available once Form Z submits so that I can send a custom email Confirmation depending on which form the information came from (i.e. Form A or B or J).
Being new to drupal development I've gotten some great assistance with this project from this site and I am very grateful to those who have been assisting me.  :)
EDIT:
So based on Remy's recommendations I have created a custom module with these two files in \modules\custom\cc_processing_getsubmissiondata:
cc_processing_getsubmissiondata.info.yml
name: 'CC Processing Get SubmissionData'
description: 'Provides a custom webform handler for retrieving the previous forms submission data'
core_version_requirement: ^8.8
Core: 8.x
package: Custom
type: module

CCProcessingGetSubmissionData.module
<?php

/**
 * Implementation of hook_form_alter
 */

 use Drupal\Core\Form\FormStateInterface;

 function CCProcessingGetSubmissionData_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    echo "form alter hook triggered";
        $form['street_1'] = '92-2000 Some Rd.';

    if($form['#webform_id'] == 'credit_card_billing_information') {
        echo "form alter form id found";
        $form['credit_card_name'] = 'Jared';
    }
 }

At this stage I am just trying to get the hook_form_alter to just do something so that I know it is being triggered.  However, I am getting nothing.  I even tried the function name CCProcessingGetSubmissionData_webform_credit_card_billing_information_form_alter but that didn't work either.  Any suggestions?


texts:
I have 3 content types that I have created: order, product and salesperson.

The fields for each are as follows:
Order: Purchaser Name, Product (entity reference to Product), Quantity
Product: Product Name, Salesperson (entity reference to Salesperson)
Salesperson: Name, Email

The way the system works is that a salesperson creates a product and then sells that product.  Each product will be tied to a salesperson (no other salesperson can sell that product). Once they receive an order, they would create "content" containing the name of the person buying the product, what product it was, and the quantity they sold.

I'm trying to figure out how to create a view that would let me allow a user to choose a product and have the view show how many of that product were sold.

Did I set this up the right way using 3 different content types with entity references or is there a better option?  If so, how can I show the sum of all the orders tied to a certain product?


texts: An invalid form control with name is not focusable. error when saving content

texts:
I've added a hidden field to the User Profile page, which I set via script. When saving the form, I get the error,

An invalid form control with name='field_map_y[und][0][value]' is not focusable.

Which from research, seems fair enough, if the field was hidden AND required. But the field is not required, and when I check the field, I can confirm this.

<input type="number" id="edit-field-map-y-und-0-value" name="field_map_y[und][0][value]" value="171" size="12" class="form-text form-number">

When I made the field visible, the form saves successfully. The error only seems to occur in Chrone.

Any ideas on how to enable the form to save with the hidden value?


texts:
I have this two test menu items:

  $items['test/%id'] = array(
    'title' => 'Test',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_module_form', 1),
    'load arguments' => array('%map'),
    'access arguments' => array(1),
  );

  $items['test/new/%new_id'] = array(
    'title' => 'Test',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_module_form', 2),
    'load arguments' => array('%map'),
    'access arguments' => array(2),
  );

Here is the fr_module_form function:

function my_module_form($form, &$form_state, $id = NULL, $new_id = NULL) {
  dsm($id, 'id');
  dsm($new_id, 'new_id');
  return '';
}

Here is the problem. When I visit (for instance): test/my-test-var
dsm(1) function returns $id => my-test-var
dsm(2) function returns $new_id =>

but when I visit: test/new/my-test-var
dsm(1) function returns the same as above which is:
$id => my-test-var so it's not $new_id as I've expected.
dsm(2) is still empty

Moreover if I visit /test/new/my-test-var/my-second-test-var I get:
dsm(1): $id => my-test-var
dsm(2): $new_id => my-second-test-var

Why do I 'tell' drupal in 'page arguments' which argument should be used? I always get the first argument from my_module_form.

How to separate it?


texts: Need help with Drupal javascript behaviors

texts:
I'm a bit lost with this and could do with some help from a Drupal JS veteran.

In my module I'm dynamically generating a settings form based on a CSS file, part of which provides a font select list with real-time updated preview text underneath. There can be any number of these font select lists + preview depending on the contents of the CSS file. The relevant (simplified) markup is something like:

  Font
  <select id="font-select-1" class="font-select" name="font-select-1">
    <option value="arial">Arial</option>
    <option value="verdana">Verdana</option>
    <option value="helvetica">Helvetica</option>
  </select>

Preview: The quick brown fox jumped etc ...

  Font
  <select id="font-select-2" class="font-select" name="font-select-2">
    <option value="arial">Arial</option>
    <option value="verdana">Verdana</option>
    <option value="helvetica">Helvetica</option>
  </select>

Preview: The quick brown fox jumped etc ...

In addition to styling (applying the correct font to) each font option I also want to change the class of #font-preview-x span to the selected option value from the relevant #font-select-x (i.e. "arial", "verdana" etc), thus showing a real-time preview of what the font will look like.

At present I have all this working OK using something like the following in my form array to change the preview text's class to the correct font class:

'#attributes' => array(
  'onchange' => "jQuery('#font-preview-" . $i . " span').removeClass().addClass(jQuery('select[name=\"font-select-" . $i ."\"]').val());",
),

This mostly works onchange but not on page load, but on reading up further I gather there is probably a cleaner and better way i.e. using '#attached' to attach a Drupal behaviour, and I also shouldn't need to pass in the specific id. With jQuery I should be able to attach event handlers to each font select that update their respective preview text.

Any direction or advice would be much appreciated, as this aspect of Drupal is relatively new to me. Have read the docs and googled around but still am a little lost.


texts: When to use Views attachments vs. content panes?

texts:
Up until now, I've always used content panes provided by Views in Panels to accomplish tasks like "Related content" and "Additional information about ABC."  I just realized that Views also provides an attachment display, which as far as I can tell seems to be similar to a content pane except it doesn't require Panels.

However, if I'm already using Panels, are there any use cases where I would be better off using an attachment instead of a content pane, or are these basically the same thing?