How to preprocess group title render in views? I tried to preprocess a title of the group in the result of the rendering of the view.

Example:

Actual:

Group 1 title
Item 1
Item 2
Item 3
Group 2 title
Item 4
Item 5
Item 6

Expected:

Group 1 title
Item 1
Item 2
Item 3
Group 2 title
Item 4
Item 5
Item 6

Here the similar question on the drupal.org https://www.drupal.org/project/drupal/issues/2950737.

If you want to change the template for the title of the group, why don't you override the template file views-view-grouping.tpl.php for Drupal 7, or views-view-grouping.html.twig for Drupal 8.

By standard Drupal templates names, overrides are also working with this one.

views-view-grouping--MACHINEVIEWNAME.tpl.php for a specific view

views-view-grouping--MACHINEVIEWNAME--MACHINEDISPLAYNAME.tpl.php for a specific display of a specific view.

Hope this can help you.


How to configure multisites for the console? Most of console commands are not listed when using

drupal list

Drupal Console version 0.11.3

It issues a warning like so:

[WARNING] In order to list all of the available commands you should install
       drupal first.

Drupal is installed , as multisites.

   drupal multi:debug

Tells me this error:

 [ERROR] There aren't multisites configured

How can I configure multisites for the console ?

     https://hechoendrupal.gitbooks.io/drupal-console/content/hu/using/how-to-use-drupal-console-in-a-multisite-installation.html

EDIT:

a mapping must be done in sites/sites.php for

drupal multisite:debug

to display the list

sites.php

 /**
 * Multi-site directory aliasing:
 *
 * Edit the lines below to define directory aliases. Remove the leading hash
 * signs to enable.
 */
$sites = array (
    'my_domain_name.fr'=>'my_folder_name_in_sites?'
);

What is the exact format of this array values i dont know

i dont have drupal multi:debug error nomore mais drupal list is still restricted

a mapping must be done in sites/sites.php for

   drupal multisite:debug

to display the list

sites.php

 /**
 * Multi-site directory aliasing:
 *
 * Edit the lines below to define directory aliases. Remove the leading hash
 * signs to enable.
 */
$sites = array (
    'my_domain_name.fr'=>'my_folder_name_in_sites?'
);

i am not sure for it to be correctly configured

my_folder_name_in_sites?

must be

my_folder_name

or

sites/my_folder_name


How to set Media Styles in Media 7.1.2 / Media 7.2.X? Where is the latest form of the component in the Media project family that allows styles to be defined for Media files?

I see a lot of references to the idea that the Media module contains, once contained, or can be compatible with, a UI component that is similar to the Drupal 7 core Image Styles system that allows formats to be defined. Apparently, once upon a time this lived at /admin/config/media-image-styles

There's a module, Styles, by Aaron of Media fame, that has a sub-module called File Styles. On the Styles project decription, it suggests that the Media module implements the API this provides in its bundled sub-module Media Styles. But the latest 7.2.x dev (and also, the latest stable version of the 7.1 branch) of Media that I have downloaded contains no such module, the URL path given for it above goes nowhere, and I can't find any such module as a seperately distributed module. Styles contains a UI module, but this seems to be unrelated to Media, and Styles hasn't been updated since 2011, whereas Media has been in near-constant development since then (with latest Media 7.2.x dev enabled, for me the Styles UI url crashes out with a fatal error Call to a member function getExternalUrl() on a non-object in... ). Also, Styles isn't even mentioned on the current Media project page.

From the way people talked about this media styles UI, it sounds like it was once a very important part of the Media project. I understand the Media project has been in a state of flux for years and documentation has lagged behind the current state of the project.

Where is the latest form of that component that allows styles to be defined for Media files?

Here's some (seemingly now all out of date) related reading:

A documentation page which mentions the path, and has some workarounds dated early 2011
An issue which led to the creation of that documentation page
Aaron's original media styles road map, explaining the rationale behind the Styles module before it was released, written in Jan 2011
Just saw this confirmation that Styles module is definitely deprecated and on its way out of the media family

Edit: Found a clue, buried at the bottom of a "Configuration" documentation page:

  The Media module used to rely heavily on the Styles module before
  Media was converted to prefer the file entity and file fields...
  defining new 'display' or view modes... can be implemented using
  http://drupal.org/project/entity_view_mode

But I can't see anything in that linked module that seems to support the kind of functionality I've seen discussed. There's a limited tutorial for the 7.2 branch which involves using Entity View Mode, but it uses it to define image styles for images, using the regular image style interface. Doesn't look to be anything for file styles for non-image files such as videos, or anything that could do anything more advanced, like have one style that shows a video's thumbnail image and another style that shows a video player. The search is still on...

A lot has changed since the madness that was http://drupal.org/node/1092444. Thankfully, theming and setting display formatters for file entities is now much easier and more straightforward.

The following documentation is for Media 2.x and File Entity, although much of it works with Media 1.x with slight alterations (e.g., in Media 1.x, the link to the "File Types" page is in Configuration instead of Structure).

Displaying Media

The File Entity and Media modules work together to provide a unified method for storing, managing, and displaying Media in Drupal. They allow a user to create file fields that can be configured to store and display many different types of media, including images, video, and audio. among others. In order to display these different types of media, file fields need formatters, often provided by the module that provides the Media type, and a little extra configuration.

Definitions

I'll explain a couple of the moving parts first, and then get into customizing the display of files on a site.

File types

Files are grouped into File Types. Each file type is defined by a list of mime types, a universal way of specifying file formats on the internet. The default file types are Application, Audio, Image, Text, Video, and Other. There is currently no way to define new file types in the UI.

View Modes

View Modes are used to tell Drupal 7 (and soon 8) that a piece of content is in a certain context. The content can then be altered or displayed in a way that best suits that context. Two view modes that most people are probably familiar with are the default teaser and full modes. Custom view modes can be defined with modules like Entity View Mode, Display Suite, or in a custom module with hook_entity_info_alter().

The Good Stuff, or: Managing the display of your File Field

A file field's display is managed per file type. Navigate to Structure -> File Types. You will see a list of available file types with links to "Manage fields", "Manage display", and "Manage file display" for each.

Manage Fields

The File Entity module makes all files full fieldable entities, the same as nodes and taxonomy terms. Just like in the "Content types" section, you can add custom fields to each file type.

Manage Display

Again, like in "Content types", you can manage the display of custom fields on each file type. This section does not control the formatting of the files themselves, only the display of fields attached to the file entity.

In this section you will also see a toggle for "Custom Display Settings". When expanded you can enable and disable view modes available for this entity. A view mode must be checked here in order for it to be available in "Manage File Display". At this time it's recommended to use only custom view modes defined by the user and the following default view modes; the rest are left over from Styles module integration and will eventually be removed:

"Teaser" (Currently not included by default. You can add it with the patch in the issue above or define it as a custom view mode)
"Full"
"Preview" (Used in admin contexts, e.g., for placeholders in WYSIWYG fields, in the Media browser, and in the Media field widget)

Manage File Display

In "Manage File Display" you can configure formatters for your file types (yes!). Many Media provider modules add their own formatters here; for example, Media: Youtube and Media: Vimeo both provide a "Preview Image" and "Video" formatter.

Formatters can be enabled and configured for each view mode enabled in their file type's "Manage Display" section. For example, a user may want to display a Media: Vimeo preview image when a node is viewed as a teaser, the Vimeo video when the full node is viewed, and a video with different width and height formatter settings when the node is viewed with a custom view mode called "video gallery". Many formatters (notably "Image") allow the user to select the image styles they have defined in Configuration -> Image Styles.

Because multiple media providers can use the same field, formatters are arranged in a top-to-bottom cascade. Drupal will use the first formatter that can be applied to the output of a field. If a video field enables the "Media: Youtube Video", "Media: Vimeo Video", and "Large filetype icon" formatters for the "Full" view mode, Drupal will use the Youtube formatter if the file's mime type is video/youtube, the Vimeo formatter if the mime type is video/vimeo, and fall back to the large filetype icon if the mime type is video/{anything else}.

Configuring the File Field to display using "Manage File Display" settings

In order for the file field to display using the formatters defined in "Manage File Display", it must be set to display the "rendered file". Navigate to the "Manage Display" page for the content type that contains your file field. Choose "Rendered file" as the file field's format for all view modes in which you would like to use the formatters defined in "Manage File Display".

Further Theming

You can create custom theme functions and template files for even more control with theme hook overrides. The theme suggestions provided by the File Entity module are:

file__{file type}
file__{file type}__{view mode}
file__{mime type}
file__{mime type}__{view mode}
file__{file id}
file__{file id}__{view mode}

Replace all '/' and '__' in mime types with '_' for theme functions and '-' for template files.

Some Media provider modules replace these with their own templates and theme hook suggestions. You can view all available theme hook suggestions with the Devel Theme Developer module, Mothership's Poor Themer's Helper, or hopefully consult the provider's docs for more info.

Outro

Hope this helps. I plan on adding this to the Media documentation, so if I missed something, misspoke somewhere, or a section needs clarification please let me know.

And some short answers to the OP's specific questions:

Media 1.x vs 2.x: even though 2.x is unstable, it's as reliable as many stable version modules on Drupal.org. I think it's worth using for the vastly improved features, but because there's so much work going on support in the issue queue is slow, and as with any dev branch new updates may break your implementation. Still, I use it on production.
Media is in development. Some things don't work as you would hope yet (e.g., non-image WYSIWYG integration). But it still works better at what it does than the combination of modules you have to install to do what it does without it. And it's getting better.


Nothing is showing in my FAQ View I installed the Frequently Asked Questions module and have created questions and answers.

I navigate to /faq-page and all I see if the title of the page "Frequently Asked Questions", but I don't see the actual questions.

I made sure:

The content is published
Permissions have been set
There is a valid 'Views' page

I even tried creating a menu item and that 's not working.

Can anyone help?

It appears to me that you are missing something in the setup of your FAQ. E.g., if you're using categorized faq nodes, then you also need to do some taxonomy vocabulary setup. Without doing so, you might suffer an issue similar to this issue.

Here are some links to Community documentation you may want to verify:

FAQ - Basic Setup Guide.
FAQ - Settings.


Drupal 7 webform Version: 7.x-4.5 not sending email After updating to Webform Version: 7.x-4.5 the email functionality is not working, which I assume it could be due to change in tokens.

I have a Webform as block a  which is attached to product content type and want to send the contact form information which is webform to current node author.

I am using [current-page:node:author:mail] token as a hidden field in the webform, which used to work until I update to new version of webform and since then the worbfrom stop sending email to author email.

What I am doing:

In the webofrm I have a hidden field author_mail where the default value is set to [current-page:node:author:mail]

At the Webform email setting I set E-mail to address to Component: Author Mail.

Any idea what token to use if not [current-page:node:author:mail]?

Is there any way to send the Webfrom content to current page author email?

Thanks for the help.

If you want to make token [current-page:node:author:mail] working, you need to apply this Token module patch.

Source.


Cannot run drush rsync - PHP Fatal error in sitealias.inc drush rsync @ dev @stage

  PHP Fatal error:  Unsupported operand types in
  /usr/local/share/drush/includes/sitealias.inc on line 1468

Drush command terminated abnormally due to an unrecoverable
Error:

  Unsupported operand types in
  /usr/local/share/drush/includes/sitealias.inc, line 1468

Found an error in my alias files. I had a space between SQL username and password.

$aliases['devyau'] = array(
  'uri'=> 'dev.[sitename]',
  'root'=> '/var/www/vhosts/dev.[sitename]/',
  'db-url' => 'mysql://[username]: [password]/devDBname',
);


Where in the database is the password reset form's expiration date set? I'd like to be able to change the text in the temporary login page but I don't know where the expiration date for the form can be found. Getting the username is simple enough and I left the login button as is. The date is the only thing left.

Alternatively, can I do this in the drupal admin without having to code anything? Something similar to the email alerts, including options for multiple languages?

The text for the One time password form is located in user_pass_reset form function in core.

While the user's password reset notification mail may be configured from the admin menu (Administer >> Configuration >> People >> Account Settings) there's no similar Admin UI based configuration of the reset form itself.

Though there doesn't seem to be a module to customize the form itself (based on my search), there do appear to be modules that offer alternative password reset methods that you could look at namely Password Reset and Simple Password Reset.

If you could consider taking a coding way, this could be achieved by using a hook_form_alter or hook_form_FORM_ID_alter

As for the expiration date drupal uses a default of 86400 seconds (24 hours). It would be stored in the variable table in the database with the name user_password_reset_timeout (note that when present the value 86400 would be serialized like all values in that table). If you wish to change this value consider doing it using variable_set through code. The equivalent drush command would appear an easier option though. Do make sure to update the email content on expiry time to avoid any confusion.


nice menus - how can I keep all sub-menu expanded in my  page? On my front page, I want to have my sub-menus expanded and have them to act as it should on other pages.

I'm using the Nice menus module.

How can I achieve it?

Use Menu Block.
Duplicate the menu with the children already expanded and then style it as the other one.


Adding a new NOT NULL field to a table causes an error When attempting to add a new column to a table within an update hook, the error Null value not allowed: 1138 Invalid use of NULL value occurred, the definition was changed to allow NULL, and the value for existing rows was set to NULL.

function MYMODULE_update_8101() {
  Drupal::database()->schema()->addField(
    'MYMODULE_table',
    'created',
    [
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ]
  );
}

When adding the column to the database with an SQL query, using the NOT NULL restriction causes the field to have a default value of 0, and no error happens.

How can the error be fixed, and the proper schema set?

If the field spec sets 'not null' => TRUE but does not define a default value, the column is created allowing null values and later altered to disallow them (see the mysql driver Schema::addField(), and the $fixnull variable).  The second query attempting add the restriction fails, causing the error.

To fix the error, either

An 'initial' value needs to be added to the spec provided to addField()

Drupal::database()->schema()->addField(
  'MYMODULE_table',
  'created',
  [
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'initial' => 0,
  ]
)

Or a 'default' value needs to be added to the spec provided to addField().
When providing a default value, the spec in hook_schema() should also be changed to match.


Issue with views and php i'm using a view thats pulls data from a certain node via refference and i show non logged in users a error that they need to login, but i need to show a special node/add link with the nid in it. i'v got the code and it works without the if statement, in the if statement, my code is not working..

<?php global $user;if (!$user->uid){print '

Oops!

tekst hier

';}else{
 (arg(0) == 'node' && is_numeric(arg(1))) {  $nid = arg(1);print 'Voeg een album toe!';} ?>

<?php  if (arg(0) == 'node' && is_numeric(arg(1))) {  $nid = arg(1);print 'Voeg een album toe!';} ?>

the code above works, but not when its in the if/else block...

Please note that i don't have great knowledge about php.

Thanks!

You should write the if-else structure like:

<?php
global $user;
if (!$user->uid) {
   print '

Oops!

tekst hier

';
}
else if(arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    print 'Voeg een album toe!';
}

?>

Note that after 'else' you want to test some conditions so you need to put an 'if' statement in front of your test.


How can I restrict access to my website via web services only? I am getting lots of spam in my website. Here are some modules I tried as a remedy:

Honeypot
Http BL

No luck yet however.

Now I decided to make the site available only for web services only, whereas the web services are done with Services module.

So how can I allow access to my website via services only? Is there something I can achieve this from .htaccess ?

Assume a setup like so:

Assume that for site access via Services you use an account called "ServicesUser".
Create a new role, say you call it "ServicesOnly".
Make sure that there are no other "custom" roles in your site apart from anonymous, Authenticated and Administrator (if there are any: remove them again).
Authorize only user "ServicesUser" for this role "ServicesOnly".
Tune your permissions where appropriate, so that:

No permissions are granted to Anonymous or Authenticated.
All permissions are granted to Administrator (but only in case you have a need to ever login without using services, with a userid different from user/1, if there is no need for that, then no permissions granted to Administrator either).

Granularly issue permissions to role "ServicesOnly", so that "ServicesUser" receives appropriate permissions whenever required.
Whenever the site is switched to maintenance mode (eg to apply Drupal updates), ServicesUser will not be able to login either, which is what you should want also.

With a setup like above, access via Services (and userid = ServicesUser) should work as desired. While I cannot think of any other user who can do anything on your site, except user/1 (and optionally some other user who has access to role Administrator).

With this configuration, these are the only ways around it that I can think of:

Some security issues that are exploited somehow.
Somehow getting access to the ServicesUser account

Note: no additional contributed or custom) modules needed either ...


Gallery with Album Covers I currently have two node types: Album (CCK), and Image (image module, using Image FUpload module).
A user creates an album, simply a title. When they create Image(s), the album is node-referenced.

I have a view of Albums, and I would like to pick one Image from each album to show as a cover photo. I cannot just add a CCK field to the Album for this; the image needs to appear in the view of album images, and every image can be voted and commented on, as well as have their own references (tags).

I tried a few relationships in the View, nothing seemed to pull the image for an album. Is this possible using the Image module?

I finally decided to add a 'Cover' cck field to the Album type. I could not find a way in Views to correctly relate an Album to a View of photos for this purpose using Relationships.


How to update Drupal securely using GUI/web interface The admin/reports/updates/update page lists updates, and there's what looks like a handy button Download these updates at the bottom.

And then you're asked for your SSH user and password.

Now unless you're running over SSL, this is a massively daft thing to do. Provide your server credentials over plain http?

If Drupal really needs to do an SSH loopback (as the help text explains, it's highly likely that the webserver is the SSH server it will connect to) in order to run updates, then surely there ought to be a way to provide the webserver's user with a DSA key so that users don't need to pass credentials in plain text.

Is there a way? Or is this really as insecure as it looks!

(I generally use SSH and drush to do updates, but as there's a GUI there, which looks nice, I feel it ought to work)

I think you are right that it's asking you to enter your important credentials over a potentially non-encrypted channel. This feature is a trade-off between doing things an optimally secure way and making it easy to get updates done. If updates are hard to do people won't do them and that is also an insecure situation.

Entering your credentials over a non-encrypted channel is only insecure if you think someone is sniffing your traffic. You can mitigate that by using a vpn or ssh tunnel (especially one that goes to the server).

Your idea to upload your private ssh key to the webpage to avoid using credentials seems at least partially flawed to me: the private key has the same value to an attacker as your ssh username/password. If you send the key on a non-encrypted channel that can also be intercepted and abused.

If you are concerned about security you can:

Add a full or self-signed ssl certificate to your webserver
Use a vpn or ssh tunnel to encrypt your non-encrypted (http) browser traffic
Just keep using ssh+drush to get the updates done


How to display multiple blocks using a custom calendar module? I have created a calendar module in Drupal 7. In addition to the default calendar on the website, my client can create a new calendar for events specific to a particular page.

Say that they want to add "Youth" and "College and Career" calendars; the db table looks like this:

table: churchcal_calendars

------id------|------name-----|------set_default------

------1-------------Main---------------1--------

------2-------------Youth--------------0---------

------3-------College and Career---------0-----------

In my churchcal.module file, I have set hook_block_info and hook_block_view:

function churchcal_block_info() {
    $blocks = array();
    $blocks['monthly_calendar'] = array(
        'info' => t('Display the monthly calendar.'),
        'cache' => DRUPAL_NO_CACHE,
    );

    //get calendars
    include('db.php');
    $result = mysql_query("SELECT * FROM churchcal_calendars WHERE set_default != '1'");
        while($row = mysql_fetch_array($result)) {
            $cal_name = $row['name'];
            $sys_cal_name = strtolower(str_replace(' ', '_', $cal_name));
            $blocks['churchcal_' . $sys_cal_name] = array(
                'info' => t('Display calendar for ' . $cal_name . '.'),
                'cache' => DRUPAL_NO_CACHE,
            );
        }

    return $blocks;
}

function churchcal_block_view($block_name = '') {
    if ($block_name == 'monthly_calendar') {
        $content = monthlyCalendar();
        $block = array (
            'subject' => t(''),
            'content' => $content,
        );
    }

        //get calendars
        include('db.php');
        $result = mysql_query("SELECT * FROM churchcal_calendars WHERE set_default != '1'");
            while($row = mysql_fetch_array($result)) {
                $cal_name = $row['name'];
                $sys_cal_name = strtolower(str_replace(' ', '_', $cal_name));
                $cal_id = $row['id'];

                if($block_name == 'churchcal_' . $sys_cal_name) {
                    $content .= churchCal($cal_id);
                    $block = array(
                        'subject' => t('Upcoming Events'),
                        'content' => $content,
                    );
            }

        return $block;
    }
}

The "monthly_calendar" is the main calendar, and there is no problem with that block.

Beneath the monthly calendar is the code for the additional calendars. I can see each calendar in admin/structure/block page (for the example "Display calendar for Youth", "Display calendar for College and Career"). That part works great. However, I can only see one calendar, and that is whichever is first in the db with default != 1. In this example, the Youth calendar would display, but not the College and Career. So, it tells me that hook_block_info is correct and there is a problem with hook_block_view.

How can I display a calendar for each calendar in the db?

It looks like you should review that "return $block;" that you inserted in the while() statement.

PS: not sure why you didn't (couldn't) post your own answer, which is why I do so now anyway ...


Problem configuring the MailChimp module I am having an issue installing the MailChimp module.  I have installed the module and the extra library under /sites/all/libraries/mailchimp/MCAPI.class.php.  I have copy and pasted my API key into the form on admin/config/services/mailchimp.  There are no errors coming up in the apache log.  The module is not functional and my lists are not syncing!

In the MCAPI.class.php Readme file says this:

  2) Try running mcapi_lists.php from the command line. Something like
  this:

`# php -f mcapi_lists.php`

But that command is not recognized.

Turns out mailchimp was working fine.  The confusion arose in that the mailchimp api doesnt populate the Lists and Users tab on my Drupal installation from mailchimp.  Instead it pushes Druapl's mailchimp lists to sync with mailchimp.  The refresh lists from mailchimp title can be quite deceiving.


File uploads: Warning: session_start(): Cannot send session cookie - headers already sent When I check watchdog, I have lots of PHP warnings like this:

  Warning: session_start(): Cannot send session cookie - headers already
  sent by (output started at
  /srv/bindings/9c42927e5316467d82a6fb1be50ed34e/code/includes/file.inc:1972)
  in drupal_session_start() (line 287 of
  /srv/bindings/9c42927e5316467d82a6fb1be50ed34e/code/includes/session.inc).

There are a lot of reports of errors like this, apparently most of which are caused by having spaces at the beginning or ends of PHP files.  But in this case, I think the problem is related to file uploads for the following reason.  The Location of these warnings are paths like this:

  https://example.com/sites/default/files/styles/profile_pic/public/pics/41207/image.jpg?itok=cdQrU8Rv

The Referrer is my "manage pictures" page, which allows users to add a Picture content type which includes an Image field.

So, it looks like session_start() is having trouble during uploads.  Is there a standard fix fox this kind of problem?

I'm also getting the exact same issue on a Pantheon hosted site. This is on a more complex content type (number of fields) with the image field using the multiupload_imagefield_widget module so we can upload multiple images. The error can also appear on removing an image, where the image field is updated via AJAX. Occasionally, a WSOD will occur.

Location or Path always relates to files/styles/....

Tried to duplicate this on a basic content type but it was not occurring. The issue appears on the main content type 80% of the time.


How to use node reference to link images of referenced node? I created a blog content type. In this content type I added a field "blog detail". I have a custom module to fetch data using node_load() in blog page. Now I want, when I click on a particular image, that this image's basic page would open using node_reference().

How can I do it?

I'ld suggest you use References. Add a node reference field into your blog content type. Finally when creating a blog node you'll reference a basic page (the one with your image).

Then check the display settings of your node reference field. Check the field formatters where you can choose

Title (linked)
Rendered Node
NID
etc...

Exactly there you have to add a field formatter now. Best by writing a small custom module. You may take the following code as a starting point:

/**
* Implements hook_field_formatter_info().
*/
function MY_MODULE_field_formatter_info() {
  $info = array(
    'linked_image' => array( // Machine name of the formatter
      'label' => t('Image (linked)'),
      'field types' => array('node_reference'), // Scope (this one will only be available to node reference fields)
      'description' => t('Display linked image if available'),
    ),
  );
  return $info;
}

/**
* Implements hook_field_formatter_view().
*/
function MY_MODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
    foreach ($items as $delta => $item) {
      // get the nid,
      // do a node_load(),
      // get your image,
      // rework it
      // $linked_image = what ever you got
      $element[$delta]['#markup'] = $linked_image;
    }
  return $element;
}


Drupal 6 - emfield is blank when logged out I have created a content type and have added the Embedded Media Field. As i was logged in as administrator everything was showing ok but when I logged out and checked the page it was empty.

The text is showing ok but the enfield fields does not show the tumbnails of the youtube videos.

When i see the node while I am logged in as administrator everything looks correct but when I log out the corresponding emfields will not show up.

Has it to do with permissions? Because I have rebuilt them.

I check the php error.log and i see no errors.

Has anyone had any similar problem?

I'd check that permissions are actually set to view this field.  If you go to admin/user/permissions you can see these as well as all permissions set on your site.


How can I add a title to a field in the checkout page? I am wondering if there is a simple way (dropdown option or checkbox) to add a title to a field in the Drupal Commerce checkout page.  Specifically, I want the second field for Street Address to have the label: Address line 2.

I was unable to find this field in Admin > Structure > View that allows the option to "Manage Display" or "Manage Form Display" and make a label for a field "Hidden" or otherwise.

I also looked in the Commerce sections to no avail.

Next step is to find out if there is a Billing Information > "Manage Form Display menu somewhere.

Not in
Home > Administration > Configuration > People > Profiles > Profile types  > Edit Customer > Manage fields
either.

Not possible in User Interface (via link or menu or whatever). But if you use the following code in a module, you can add a title to your form element:

<?php
function CUSTOM_form_alter($form, $form_state, $form_id) {
  // You should probably check for a form_id in here, as this runs on every form.
  // Below you will need to find the part of the $form array that has the billing address.
  $form['[see note above]']['widget'][0]['address']['address_line2']['#title'] = t('Address 2');
}


Drupal commerce: Purpose of utilizing different product types? I'm trying to figure out product types in Drupal commerce. Why would you want to use more than one product type?

Couldn't you just use one product type?

I could see that different product types have different fields. Is that the primary reason?

Or is it because there an ease of use for utilizing product types in views?

Different set of fields should be the main reason for different product types. In my opinion, it is the same reason which puts us in the position of creating new content types.

Different set of fields might seem trivial, but if you are using rules/triggers to do different things to a unique set of fields, then that's altogether a different feature.

Hope this explains the difference.


Displaying content according to the OG membership of the creator In our Drupal 7 site, we are using Organic Groups to create private groups. Users are also able to upload content to a gallery (using custom Content Types "Gallery image" and "Gallery video"). On users' profile pages, we are showing a carousel of their N most-recent uploads, with a View using a Contextual Filter on Author uid.

We would like to add a similar carousel to each OG group page, showing the most-recent N uploads by members of the group. [Edit: This is uploads to the general Gallery, the OG groups do not have their own galleries.] If it makes a difference, almost all users will be members of more than one group (for reasons that are unimportant, there are two kinds of group: geographic groups and interest-based groups).

This seems like it's probably very easy, but I just can't see how to do this, either from the View's Contextual Filters or the View's Relationships.

Am I missing something obvious?

In Drupal 6 you would add a relationship to the Organic Group: node then filter by Organic Group: user and use the relationship. I believe it should be something very similar by using the contextual filters...


How to make URL arguments available as tokens in Rewrite Results of a Field in a View? Is it possible to make URL arguments, e.g.

http://mysite.com/arg1/arg2/arg3

available as tokens in the rewrite results settings for a field in views e.g. for the above these would be available for use (among other existing tokens) as:

[arg1] [arg2] [arg3]

Background

I am developing Views using OpenLayers maps with filtered items place in an overlay on them. When the user interacts with the map to remove items, I want to retain the position of the map (an not have it revert to a default zoom and position) when the page reloads. By being able to access the URL arguments i.e. longitude and latitude, I can then rewrite the filter URL so that these are sent back to the page.

But I'm sure there are other scenarios that don't use maps that people would find answers to the question useful for.

If you do not want to actually use a contextual filter, you can use a "Global: Null" contextual filter, use the Contextual filters options to assign the value from the argument position you are interested in and then that becomes available as a %1/!1 replacement token without actually affecting the query.


Gaining access to hooks in contrib modules: Webform Validate Imagine the scenario: You installed Webform and Webform Validation. You got a Webform. You set some validation rules. Say, question #1 must be answered "True" and #2 must be "False" or else you failed and you can't submit your form.

So then, you want to override the validation. But you don't want to change the validation criteria, just the actions. Instead of just tossing out a drupal_set_message for each one, you want to count up how many validated and how many didn't. You want to display to the user the correct validation condition for some, but not all, and you want to do it depending on the count.

So where does Webform hide its validation criteria once they've been set? Node_load doesn't show them to you. The Webform API don't give you no love. Because they're stored away by a separate contrib module.

Where do you go?

Webform Validation can help you in this regard. And there is a way to define custom validation rules too through hook.


How to add meta title? I want to add this line above my title

<meta name="viewport" content="initial-scale=1.0, width=device-width,  minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />

How can I ?

You can put this on html.tpl.php in drupal 7 , else you can have it on page.tpl.php.

As a note if you are putting it on page.tpl.php remember you have to put it on every other page overriding template page--front.tpl.php etc.


Override a node template suggestion with template in custom module We have a content type that is added to the drupal system Programmatically when we install one of our custom modules. Essentially the module handle incoming property data from a 3rd party and creates a node entity for each property.

The content type created is named properties and as such its template suggestion shown in Twig debugging is node--properties--full.html.twig, see below:

I am creating a second custom module called lrg_property_display and my intention is that this module will handle all the rendering related functionality as I want to keep the API import related functionality separate from the rendering. My module structure is shown below:

I have created my module and followed a couple sites suggestions that I simply create a template file in my module and in the .module file implement the HOOK_THEME method, which I have done as shown:

function lrg_property_display_theme($existing, $type, $theme, $path)
{
    $theme['node__property_display__full'] = [
        'template' => 'node--property-display--full',
        'base hook' => 'node'
    ];

    return $theme;
}

Clearing cache and refreshing the page though is showing that the theme is not been applied.

Where am I going wrong with this please? I basically need the node--property-display--full.html.twig template within the module to be used whenever a node of the type Properties is viewed.

UPDATE

I added the following code to my theme file (Theme name is white_label) which seemed to produce an error which suggests it 'almost' works, albiet I'd prefer not having to do a suggestion in the theme but want it in the module. I can live with it though if this works for the short/medium term:

function white_label_theme($existing, $type, $theme, $path)
{
    return array(
        'node__properties__full' => array(
            'render element' => 'elements',
            'template' => 'node--property-display--full',
            'base hook' => 'node',
            'path' => drupal_get_path('module', 'lrg_property_display') . '/templates',
        )
    );
}

This then looks for the template node--property-display--full.html.twig but its looking in the main theme directory not in the module, even with the path specification.

The error returned was:

he website encountered an unexpected error. Please try again later.Twig_Error_Loader: Template "themes/custom/white_label/templates/nodes/node--property-display--full.html.twig" is not defined.

Reference image for comment in @Leigh's answer

Isn't your array key wrong? It should be:

 $theme['node__property__full'] = [
    'template' => 'node--property-display--full',
    'base hook' => 'node'
];

If you're wanting to target the "full" display and your content type has a machine name of "property"

I'm doing something similar targetting a node of type "news" and display node "teaser":

function mymodule_theme($existing, $type, $theme, $path) {
  return [
   'node__news__teaser' => [
      'template' => 'node--news--teaser',
      'base hook' => 'node'
    ],
  ];
}

And my folder structure is:

/modules/custom/mymodule/templates/node--news--teaser.html.twig


Drupal 8, override template menu in custom module doesn't work, theme template is called instead I Want create a custom module with custom template for override a menu created from the back office administration. I don't want put my custom template in the theme, I want put this file in my custom module (in custommodule/templates/..)

1) I activated twig debug, I can see what is the suggested template menu name : (menu--main.html.twig)

2) I added in my custom .module file the hook theme :

function custommodule_menu_theme($existing, $type, $theme, $path)
{
  return array(
    'menu__main' => array(
      'base hook' => 'menu',
      // 'render element' => 'menu', // I tried this, nothing change
      // 'template' => 'menu--main', // I tried this, nothing change
    ),
  );
}

3) From my custommodule, I created a directory 'templates'. In this directory, I add the twig file menu--main.html.twig :

<h1> Hello ! <h1>

4) I cleared caches (drush cr)

5) I reloaded the page from my browser. I noticed my custom template isn't called. And if I look in the html structure page, I see :

Why this is the template from the global theme called ? and not my templates/main--menu.html.twig ? I don't understand..

UP

My new code :

function custommodule_theme($existing, $type, $theme, $path) {
  $theme=array();
  $theme['menu__main'] = array(
    'base hook' => 'menu',
    'render element' => 'menu',
      );
  return $theme;
}

But my custommodule/templates/menu--main.html.twig is still not called (I cleared caches). My page always uses the themes/boostrap/templates/menu/menu--main.html.twig in the

Your module function custommodule_menu_theme() is incorrectly named so hook_theme() isn't evoked and returning incomplete output; it needs, at least, the base hook & render element elements entered so that it knows what hook to target and the render array to supply to the template.

/**
 * Implements hook_theme().
 */
function custommodule_theme($existing, $type, $theme, $path) {
  $theme = array();
  $theme['menu__main'] = array(
    'base hook' => 'menu',
    'render element' => 'menu',
  );
  return $theme;
}


The module Node Embed does not work for a custom user role I am trying to use the Node Embed module with WYSIWYG editor in Drupal 7 to embed a node. I can do this as an Admin but cannot do it as a custom user role. It says Access Denied when I go to the WYSIWYG editor and the Node Embed plugin. I did check for the permissions for WYSIWYG profiles and also text formats. The custom role has permissions to use/access both. Any thoughts on this? Any help would be appreciated.

In the Module Documentation for both CKEditor Integration and WYSIWYG Integration it says:

"Enable the default view 'ckeditor-node-embed' (if its not already enabled). This view provides the content of the 7plugin dialog box."

The access to this view is "Permission | Administer Content"

If your custom roles do not have this permission it won't work.

I altered the access to be by Role and selected roles I wanted to be able to use Node Embed and it then worked.


Overlay in Views not Working I am using Views 7.3.8 with Drupal 7.30. I use this combination for a total of 5 individual sites.

On 1 of my sites when I go into any view>>> edit page and try to click on field/title or any link on the edit page, the overlay pops up with a blank screen and just sits there empty.

I have tried disabling along with several other things short of uninstall/reinstall.

Any ideas?

This error usually causes due to Jquery version incompatibility, try installing jquery_update module and navigate to

example.com/admin/config/development/jquery_update

and choose jQuery version for administrative pages as 1.5 or 1.7


Clues integrating jcart in Drupal 7 jcart is a great shopping cart that uses a php class inside a jcart.php file. The cart is being displayed

<?php $jcart->display_cart();?>

I managed to create a module to list the product items and the form with 'add to cart' button, also to include the jcart.css and jcart.js inside everypage. The only thing I need to include more are:

the mymodule/jcart/jcart.php

I tried to include it in my header of html.tpl.php but I get an error while displaying $jcart->display_cart(). The error is:

  Fatal error: Call to a member function display_cart() on a non-object
  in...

To add a class to the form: class

If there is someone could help I would appreciate it.

You need to include the file itself, module_load_include can help you with that. Then you need to instantiate the class, you should read the docs about jcart to figure out how to do that, but something like

 $jcart = new jCart($args);

This can be done in your theme, or ever better create block in your module than will display the cart and that will invoke display_cart.

Note I don't know anything about jcart, and as such the code is just an illustration.


Let authenticated users (non-admin) reorder uploaded images using the 4-way arrow Currently, the admin is able to reorder uploaded images (field), using the 4-way arrow, like so:

But other authenticated users(not admin) can only reorder images through "Show row weights":

but it gets tedious when there is more images. Is there a way to enable the 4-way arrow for them?

Turns out the draggable link is present, but only the bottom 10% of it, and the 4-way icon does not get rendered, even though the background is set in css.

This problem is due to the import of scaffolding in the the bootstrap scss file.


Change select list to radio buttons. I want to modify my register page and add some fields from 'profile' content, for example: gender.

So Ive got:

function mysite_preprocess_user_register(&$variables) {
   unset ($variables['form']['Personal Information']['profile_gender']['#description'] );
   ....
}

In this point when i print_r profile_gender Ive got:

Array ( [#type] => select [#title] => Gender [#default_value] => [#options] => Array ( [0] => -- [Select] => Select [Male] => Male [Female] => Female ) [#required] => 0 [#post] => Array ( ) [#programmed] => [#tree] => [#parents] => Array ( [0] => profile_gender ) [#array_parents] => Array ( [0] => Personal Information [1] => profile_gender ) [#weight] => 0.003 [#processed] => 1 [#attributes] => Array ( ) [#input] => 1 [#size] => 0 [#multiple] => [#process] => Array ( [0] => form_expand_ahah ) [#name] => profile_gender [#id] => edit-profile-gender [#value] => [#defaults_loaded] => 1 [#sorted] => 1 )

And when I want to change #type to 'radios' displays me nothing..

Like:

  $variables['form']['Personal Information']['profile_gender']['#type'] = 'radios';
  $variables['form']['Personal Information']['profile_gender']['#options'] = array('0'=>t('Male'),'1'=>t('Female'));
  $variables['form']['Personal Information']['profile_gender']['#default_value'] = 'Male';

    $variables['gender'] = drupal_render($variables['form']['Personal Information']['profile_gender']);

Any ideas how to change that from select list to radios(male/female)?

The preprocess functions are about rendering the output. Removing and adding form element with FAPI must be done earlier.

You have to do this with hook_form_alter. It's also very likely that you have to add a custom submission handler to process and save the user input. You can hook in your handler in hook_form_alter as well.


How to auto-submit a form using Drupal Form API? I need help with making a drupal form. I've made the form and it works perfectly fine, all it does is capture the email, ip, and date and time of a user. The problem is I don't want the user to have to click a button in order to submit the form, I want the form to automatically submit after a second or something.

//form hook, form elements start here

function form_casl_form($form, &$form_state) {
//sometext here
 $form['some_text'] = array(
    '#markup' => '
Simply click the button to subscribe.

'
);

  //submit button
  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Subscribe'),

  );
  return $form;
}
    //validate hook

Is there anyway to do this? I'm very close to finishing and this is the only thing I'm stuck on, any ideas would be appreciated!

This one is a pretty easy method by adding 'onChange' to the '#attributes' array:

/**
 * Custom form handler.
 */
function FORM_EXAMPLE($form, &$form_state) {

  $form['complete_projects_radios'] = [
    '#type'          => 'radios',
    '#title'         => t('Project status'),
    '#default_value' => 0,
    '#options'       => [
      0 => t('Current'),
      1 => t('Complete'),
    ],
    // Define the onChange like so:
    '#attributes'    => [
      'onChange' => 'this.form.submit();',
    ],
  ];

  $form['complete_projects_submit'] = [
    '#type'       => 'submit',
    '#value'      => t('Apply'),
    // The submit itself is necessary, but now it can be hidden:
    '#attributes' => [
      'style' => ['display: none;'],
    ],
  ];

  return $form;
}


Convert hook_menu in drupal 8 I have a hook_menu as follows :

/**
 * Implementation of hook_menu().
 */
function conditional_fields_menu() {
  $items = array();

  foreach (node_get_types() as $type) {
    $content_type = content_types($type->type);

    $items['admin/content/node-type/' . $content_type['url_str'] . '/conditional'] = array(
      'title' => 'Conditional fields',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('_conditional_fields_admin', $content_type['type']),
      'access arguments' => array('administer conditional fields'),
      'type' => MENU_LOCAL_TASK,
      'weight' => 5
      );
  }

  return $items;
}

How can i convert this to conditional_fields.routing.yml in d8 ?

what i tried :

Drupal 8 conditional_fields.routing.yml snippet

conditional_fields.admin:
  path: 'admin/content/node-type/{this is unknown}/conditional'
  defaults:
    _form: '_conditional_fields_admin'
    _title: 'Conditional fields'
  requirements:
    _permission: 'administer conditional fields'

The routing system uses pattern matching. You can define a parameter in the path that will be used as a variable.

If we look at this snippet of node.routing.yml:

node.add:
  path: '/node/add/{node_type}'
  defaults:
    _controller: '\Drupal\node\Controller\NodeController::add'
    _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
  requirements:
    _node_add_access: 'node:{node_type}'
  options:
    _node_operation_route: TRUE
    parameters:
      node_type:
        with_config_overrides: TRUE

You can see the {node_type} in the path. This variable will contain the node type as specified in the path. You can use that as part of the requirement as you can see above, and it will also be available to your functions. \Drupal\node\Controller\NodeController::add receives the node_type variable as well:

public function add(NodeTypeInterface $node_type) {
  $node = $this->entityManager()->getStorage('node')->create(array(
    'type' => $node_type->id(),
  ));

  $form = $this->entityFormBuilder()->getForm($node);

  return $form;
}

Read Parameters in routes for more information.

And for forms:

example.user_form
  path: 'example/form/{user}'
  defaults:
    _form: '\Drupal\example\Form\ExampleForm'
  requirements:
    _permission: 'access content'

You can use the buildForm function and place the additional parameters after $form and $form_state.

namespace Drupal\example\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Session\AccountInterface;

class BasicForm extends FormBase {

 public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $user = NULL) {
    // Do something with $user in the form
  }
}


How to programmatically create a custom token in a module How would you go about programmatically creating a token? I wish to add some custom tokens for my module.

In Drupal 7 the code for handling tokens is part of the Drupal core module.

The hooks the token modules need to implement are:

hook_token_info() is the hook that provides information about the tokens implemented by a module.
hook_tokens() is the hook that needs to be implemented to provide the actual values that replace the tokens.

Other modules can alter the token implementation provided from a module using hook_token_info_alter() and hook_tokens_alter().

Differently from the Token module, the code in Drupal core allows to create the content of a token only when strictly necessary.
In Drupal 6, the Token module would ask to the modules implementing tokens all the values for their token using hook_token_values(); this means that a module can compute the value for a token which is then not required for the tokens being replaced. In Drupal 7, the implementation of hook_tokens() receives $tokens, an array of tokens to be replaced, as argument; the module is then able to compute the value of a token, knowing it will be used.

The function that in Drupal 7 is used to replace the tokens with their value is token_replace(), which is the only function used to replace the tokens with their values.

Other difference between the Token module for Drupal 6 and the code in Drupal 7 are:

In Drupal 7, [node:author] returns the name of the author; [node:author:mail] returns the email address associated with the author of a node, and [node:author:url] returns the URL of the user profile for the node author. In other words, it is possible to use [node:author:xyz], where "xyz" is one of the tokens returned for a user object.
In Drupal 7, there are not raw tokens; the implementation of hook_tokens() get a parameter that tells to the hook when the content of the token needs to be sanitized; when the token value doesn't need to be sanitized, the content is not passed to the functions check_plain() or filter_xss().
In Drupal 7, there isn't any function that show the list of the available tokens. If a module needs to show the list of available tokens, it must build the list of the tokens itself and show it in the description of a form field; alternatively, it can use the theme function still available in the Token module.


How does Drupal generate form ID for a form? Following is the code snippet I used to generate a the User Profile edit form:

print drupal_render(drupal_get_form('user_profile_form'));

However, I could not find the declaration of the 'user_profile_form' form id anywhere in the Drupal system. So I assumed that it is generated dynamically, but I am not sure.

So, If it is already defined, Where is it defined?
and if it is generated dynamically then how does Drupal generates these Form IDs.

user_profile_form is defined in user.pages.inc file in user module directory.

The id of the form is the function name which generate the structure of the form in Drupal System. When we call drupal_get_form, it call function name to build the form array.

There is a function drupal_prepare_form in form.inc in includes directory of the Drupal root.

  drupal_prepare_form function prepares a structure of the form array
  and adds required elements, executes any hook_form_alter functions
  and optionally inserts a validation token to prevent tampering.

Code Snippets to generate form id:

if (!isset($form['#id'])) {
    $form['#id'] = drupal_html_id($form_id);
  }


How to move drupal site from remote server to localhost? I have a drupal site running currently on bluehost.
The site is big and I want to test every thing I change on local host before doing it on production site.

Unfortunately, I can not move it to from the remote server to local host.

Can someone give me the basic steps needed to move site from remote server to my local host (aquia dev desktop)?

I am not sure your site has SSH access and you can access it, but certainly you have FTP access to your site.
Suppose your drupal directory is /public_html/mydrupalsite/; with FTP managers like FileZilla or CuteFtp access your site. Download all the files that are in the mydrupalsite directory, then  go to phpmyadmin on your site, and select your database; open the export tab, and export your database without changing any setting.
Install PHP, Apache, and MySQL server on your computer, copy the files to the directory that can run in your local host, create a new database, import the  database, and change the parameters in the settings.php file.


How do I programmatically disable a form? I want disable the user register form depending some conditions. The user go to the "/user/register" page, and he must see 'Registration is disable because ...'.

From my "form_user_register_form_alter" hook, I don't find anywhere how can I disable all the form programmatically (I mean removing all fields form). I think I can unset all form elements, but I feel that is an ugly way.

Is there a method (from the FormStateInterface class) or a Drupal function (for the form variable) to properly disable the form?

This is my most recent tentative.

function mycustommodule_limit_form_user_register_form_alter(&$form, FormStateInterface $form_state){
  if (...) {
    $form['#access'] = FALSE; // Drupal 7 (ugly?) way
    drupal_set_message('This form is disable because...');
  }
}

When I go to the /user/register form, the form is disable ! but I get this error.

  Notice: Undefined index: #markup in Drupal\Core\Render\RenderCache->getCacheableRenderArray() (line 323 of core/lib/Drupal/Core/Render/RenderCache.php).

I would like to hide/remove Create new account too.

The D8 way to do this is to write a custom access check.

This is the one which now checks the access for the user register form:

src/Access/RegisterAccessCheck.php

<?php

namespace Drupal\user\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Access check for user registration routes.
 */
class RegisterAccessCheck implements AccessInterface {

  /**
   * Checks access.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account) {
    $user_settings = \Drupal::config('user.settings');
    return AccessResult::allowedIf($account->isAnonymous() && $user_settings->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY)->cacheUntilConfigurationChanges($user_settings);
  }

}

user.services.yml

services:
  access_check.user.register:
    class: Drupal\user\Access\RegisterAccessCheck
    tags:
      - { name: access_check, applies_to: _access_user_register }

user.routing.yml

user.register:
  path: '/user/register'
  defaults:
    _entity_form: 'user.register'
    _title: 'Create new account'
  requirements:
    _access_user_register: 'TRUE'

Put these files in a module and change user to mymodule and choose a custom class name.

To successfully override the route in mymodule.routing.yml you have to adjust the module weight. Or instead change the access settings of the existing route in a RouteSubscriber, which is a bit more work to do, but the better solution.


Content profile title token I need a content profile title token. I downloaded this small module, but it works only for text_field and I need a title.

Did you try the Content Profile Tokens module? It is a sub-module of content profile 1.x.

Your content profile title could be a node title or a CCK field; the token [title] or [field_titlefieldname-raw] will provide the value you expect.


Why am I getting an error message in my dashboard for unprotected private files? I have a site with Drupal 8.9
Why am I getting an error message in my dashboard for unprotected private files ?
When I go to the link it says this is for Drupal 6 and 7.
PRIVATE FILES DIRECTORY
Not fully protected
See https://www.drupal.org/SA-CORE-2013-003 for information about the recommended .htaccess file which should be added to the private:// directory to help protect against arbitrary code execution.

https://www.drupal.org/forum/newsletters/security-advisories-for-drupal-core/2013-11-20/sa-core-2013-003-drupal-core

The error, which is reported by system_requirements(), means that either that directory doesn't contain any .htaccess file, or that .htaccess file doesn't contain the following lines.
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

Together the lines added from a previous security advisory, they avoid files in that directory can be executed.
# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

Before showing that error message, Drupal tries to create the .htaccess file. (See HtaccessWriter::write().) If it's not able to create it, or write into that file, you should manually create the .htaccess file containing the following lines.
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
  Require all denied
</IfModule>

# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
  Deny from all
</IfModule>

# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php7.c>
  php_flag engine off
</IfModule>

The same lines are shown in the error message contained in the Drupal log.


Placeholder working, but giving Notice: Undefined variable: value and Notice: Undefined index: #type This is what my code looks like:

foreach ($form["submitted"] as $key => $value) {
    if ("textarea" == $value["#type"]) {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
    if($value['#type'] == "webform_email") {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
    if($value['#type'] == "file") {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
}

Why are these errors there and what is the solution? A detailed explanation and working code wouldn't hurt, I am a beginner with Drupal! :-)

There can be some form elements, for examples, markup, without an explicitly set #type.

foreach ($form["submitted"] as $key => $value) {
    if (!isset($value["#type"])) { //If #type is not set, skip this iteration.
      continue;
    }
    if ("textarea" == $value["#type"]) {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
    if($value['#type'] == "webform_email") {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
    if($value['#type'] == "file") {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
}


Printing outout of a view in to a field in user profiles I have created a view which prints only usernames of registered users .

In user registration there is field named "father username" .  i want that field to be populated as a list from the above view .

i used view reference , but it just shows all the views in the site .

any clue ?
thanks :)

I'll make an assumption, and answer based on the assumption. The assumption is that the field "Father username" is an entity reference field, and you want to use the view of registered users to populate the options for that field.

If that is so, you need to create an "entity reference" view display, then refer to that view display in the field settings of the "father username" field.


Which backup system is good for my local project? I'm using ubuntu, and I accidentally deleted my project last weak. I tried to recover it but no luck.

Which is the best way to backup my project automatically including my Database (my database is Mysql)? What do you recommend?

First of all, let me just state the obvious: the solution that I'm about to propose is not going to bring your files back; it is a measure that you'll have to take from now on in order to prevent similar disasters in the future.

Basically, since you are working in your local machine (if you were working in the cloud you could automate a snapshot-taking process) you will have to keep a backup of 2 different things: the files and the database. Assuming that you are following the "drupal best practices code" and you are keeping every new file in the sites folder of your drupal installation, all you have to do is keep a regular backup of this folder and the database. So:

1) Regarding the "sites" folder: you can create a simple cron job that will compress and archive the folder regularly (even though it is out of the scope of this answer, you can find more information on crontab here)

2) Regarding the database: the solution here is actually pretty simple: "Backup and Migrate" module. It gives you the option to schedule your database backup and save the file through FTP in a remote server, send it through email or save it in your local machine. It's basically more than you'll ever need for this purpose.

P.S: I'm pretty sure that you will get some answers that you should be running a version control system to avoid things like that in the future. It's true that a version control system would be the ideal way to make sure that your files will not be lost in the future (the database is another story). However, the solution that I mentioned above is considerably faster and can get you up and running in no time. If you have time though, I would strongly suggest that you take a look at SVN or GIT (or any subversion control system that you like for that matter).

P.P.S: If the data that you lost is important, you can do a google search for data recovery software. A very quick search that I did gave me this.


How can I understand when hook_form_alter() is called? In Drupal 8, hook_form_alter() is invoked multiple times: at page load, submission, after executing custom submission handlers, and back to form action.
How can I see at which stage hook_form_alter() is invoked?

The lifetime cycle of a form and its stages depends on whether the form is rebuilding and using Ajax. Most times you react then on the form action you find in:
$form_state->getTriggeringElement()
The two different calls between page load and before the first submit is because the original form build is not cached and then has to be built the same way as the first one. Normally you don't care and alter the form build the same way for each call. If you need to make a distinction between both calls you find the raw submitted values in $form_state->getUserInput()


Modifying the core tracker module I would like to modify the styling of the tracker module and also move it's content from a separate user profile tab to the main tab. What is the best way to accomplish this? Modifying the core module would be a bad idea right? I may also want to edit the module to change functionality.

It's the best to clone the module, rename it to let's say "custom_tracker" and there do the modifications you need.

As I did this few times with other modules, here are some tips:

Rename with "custom" prefix/suffix to avoid name clashes. Don't forget to rename all function and variable (I mean the stored ones) names as well as all the files (tracker.module => custom_tracker.module)
Test the module in local before using it on the live site.
As the module isn't too big, I suggest reading all code and do the renaming manually. It's better than simple replace as it might remove/screw wrong parts and also you can better understand the module.
If you would like to be able to improve the module later on, mark the changes/additions you made so later on if the module gets updated you can merge/add those improvements to your module as well.


Get all nodes of given type I would like to get all nodes that are of my_custom_type type in Drupal 8.

I know I can get all the nodes (of any type) with \Drupal\node\Entity\Node::loadMultiple() and the list of all types by \Drupal\node\Entity\NodeType::loadMultiple().

But how to get only the nodes of given node type?

I really don't want to use specialized module for it (if it's possible), just keep it as simple as possible. I will use the solution in my custom module.

And loading all the nodes with \Drupal\node\Entity\Node::loadMultiple() and then check their type in foreach would hit the performance too much.

You can use Drupal::entityQuery() & Node::loadMultiple() to load all the nodes of your given type:

$nids = \Drupal::entityQuery('node')->condition('type','my_custom_type')->execute();
$nodes =  \Drupal\node\Entity\Node::loadMultiple($nids);


Prevent redirection after comment submission When a user add a comment on a node, I would like to prevent the page reload.

I added a form_alter in my theme

function theme_form_alter(&$form, &$form_state, $form_id) {
    switch($form_id) {
      case 'my_form_id':
        $form_state['redirect'] = false;
      break;
  }
}

But this is not working.

I also tried to replace $form_state['redirect'] = false by $form_state['redirect'] = false but it seems to be the Drupal 7 way to do this.

how could I achieve that on Drupal 8 ?

EDIT

I tried to use a submission handler

function theme_form_alter(&$form, &$form_state, $form_id) {
        switch($form_id) {
          case 'my_form_id':
            $form['#submit'][] = 'theme_form_submit';
          break;
      }
    }

function theme_form_submit(array $form, FormStateInterface $form_state){
    $form_state->disableRedirect();
}

But it's still not working.

Use FormStateInterface::disableRedirect(), e.g.

$form_state->disableRedirect();

Make sure you run that code in a submit handler for the form, not in the form alter hook.


How to view content from admin theme (Seven), when logged in as admin I use Drupal 8.2.3 and can't view content in my admin theme (seven), when logged in as admin (I can only view management pages with Seven, but not content pages as in general).

I thought that this would help but it doesn't:

Drupal doesn't treat Content/Node view page as admin pages even after enabling "Use the administration theme when editing or creating content" setting on "Admin => Appearance" Page. This is just a setting allowed by Drupal Core. Node module uses this setting and alter Content/Note edit, delete, revision, etc. page URLs so Drupal can treat these path as Admin path.

You'll have to alter route defined by Core's Node module. You can do this by implementing alterRoutes() and tell Drupal to treat Content View page as admin URLs. Check example below:

namespace Drupal\example\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.node.canonical')) {
      // Node module has option to define all path as admin path,
      // where path has "_node_operation_route" option set to TRUE.
      $route->setOption('_node_operation_route', TRUE);
      // Below line define path as admin path.
      // $route->setOption('_admin_route', TRUE);
    }
  }

}

If Use the administration theme when editing or creating content setting is enabled then, the Node module checks if any path has _node_operation_route option set to TRUE. If yes, it alters the path and set _admin_route option to TRUE so the path will be treated as an admin path (and then you will see it as in an admin theme, which is in this case, Seven).

If this doesn't work you can specifically set _admin_route option to TRUE for Content/Node View (entity.node.canonical) page programatically (check commented code).


How do I install Drush 9 on Windows 7 with Composer? Should I globally install Drush and use it locally, or should I use install and use it locally?

I globally installed it with Composer, then added C:\Users\Md. Shafiq Hossain\AppData\Roaming\Composer\vendor\drush\drush to the PATH variable.

When I change the current directory C:\My Work2\src\Drupal\clientname\projectname and type drush version, it gives me the following error.

  'C:/Users/Md.' is not recognized as an internal or external command, operable program or batch file

I tried with the project wise. I installed correctly, but drush version returns the following error.

  Drush is not recognize as internal or external command

If anyone can help me on this will be great.

The Drush 9 documentation is pretty clear: Install Drush locally, in your Drupal site, using composer. You can install Drush Launcher in addition if you want it more convenient.

Without Drush Launcher, you can use the site local Drush be running

vendor\bin\drush some-drush-option

from your Drupal site root. No need to modify any paths.

If you install the Drush launcher (and use Windows), create a suitable bat file.

NB! Adding C:\Users\Md. Shafiq Hossain\AppData\Roaming\Composer\vendor\drush\drush to the path is plain wrong. If you really want to modify the path (to get the convenience of using just drush without installing Drush Launcher), the correct path is [...]\vendor\bin.


Not able to access "Updates" page logged in as admin user I am running a site on Acquia's dev cloud, using Acquia's Dev Desktop and sometime in the last few months something has changed to prevent access to the Update tab inside admin/modules/update. I'm logged in as the drupal admin, but when i try to access that page i get:

  You are not authorized to access this page.

Also on that page, cron had stopped running regularly. When I tried running manually, it would give me the same error

What worked for me was rebuilding permissions under "/admin/reports/status/rebuild" (Make sure to take a db backup).

Right after rebuilding, I saw all the available updates.

Thought this might be of help to someone.


How to create a new entity that is fieldable I am currently learning how to create entities in Drupal 7. I have successfully defined a new entity and made it fieldable. My question is how do a create a new instance of that entity? I understand that if I want to create a form in a normal module I use the field API to create the form to collect the information that I want. Since the entity is fieldable, I am assuming that there must be a function that creates the form for you based on the form elements that you have defined. I mean that would make sense considering the field definitions are stored in a consistent format in the database so it would stand to reason that a function could be created to automate the process of creating the form from that information. I assume this is what happens when you create a new article that has had fields added to it.

Does anyone know what this function is or what the proper procedure is to accomplish this task?

I am assuming that there must be a function that creates the form for you

Not quite - you need to create the form yourself with the API as normal, but you can use field_attach_form() to have the field elements added automatically. You'll also need the complementary field_attach_validate() and field_attach_submit() in your form's validate and submit handlers respectively.

Elements for your entity type's properties need to be added manually.

The best place to look for code examples is the entity example module in the Examples project, it has all of this in it and is pretty well commented.


How to process html in twig file I've a plain text field, where I've added few text in wrapped in  tag. I've tried to get the processed html text in the twig by using

   {{ content.field_front_page_description|field_value }}
    {% set text = content.field_front_page_description|field_value %}
      {% set build = {
      '#type':   'processed_text',
      '#text':    text|render,
      '#format': 'full_html',
      } %}
      {{ kint(build) }}
      {{ build }}

But it is returning an array with not processed text. How do I do that

Edited Code -

{% set build = {
      '#type':   'processed_text',
      '#text':    content.field_front_page_description.value,
      '#format': 'full_html',
} %}
      {{ kint(build) }}
      {{ build }}

Or,

{% set build = {
      '#type':   'processed_text',
      '#text':    node.field_front_page_description.value,
      '#format': 'full_html',
} %}
      {{ kint(build) }}
      {{ build }}


Get custom comments of node I'm currently working on a simple reviewing system. I've created a custom comments type ("Review") with an integer list ("Rating") that can be added to my nodes. Now, while displaying the note, I would like to get an average rating based on the reviews posted.

I am quite new to Drupal, and I thought that I might achieve this by creating a custom twig template for the product-type nodes and getting the required value in a preprocess function.

I succeeded in getting the field_reviews object with

$variables['comment_field'] = $node->get('field_reviews');

and when I kint()ed it out, I got a really big file structure, but the required data was in there.

However, whenever I tried following the path down there through dozens of variables and arrays, when I reached the review itself, kinting yielded NULL or the page didn't load at all.

I'm getting the feeling that this approach is not ideal and that I must've overlooked something much easier, but I can't seem to figure out what.

The comment field doesn't contain the comments, it just contains settings and statistics (e.g. open or closed).

To get the comments, you need to do an entity query and get all comments that have point to your node of your type, load them and then calculate the average from them.

Also, see http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet on how to work with content entities and fields. kint() is highly misleading and confusing.

Update. Instead of having to load all comments and calculate the average yourself, you should be able to do an aggregate entity query and get the average value of your field directly: https://www.drupal.org/node/1918702


How can you allow an unregistered user to change languages? I have no clue to which is the Drupal way of allowing any user (registered or not) to change the website language.

The way I need it to work is to allow any user to click on their preferred language flag and just change the interface language.

What modules should I look into?
Is there any function I should be calling when clicking the flag?

Any link to something resembling a walktrough is also appreciated.

If it's just the interface you'd like to translate, then I think you can get by with Locale (a core module). If you want content translation (and many other things) you can use i18n. The project page for i18n gives you plenty of links to follow for other projects and documentation.


Drupal in subfolder, clean urls and images (htaccess not quite right) I have my Drupal installation in a subfolder and it's working ok, but there's one problem. New images can't be generated from image styles unless clean urls are turned off.

This is my .htaccess in the root:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
# Redirect all user to without WWW
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

#files
RewriteCond %{REQUEST_URI} ^.*\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !^/drupal/
RewriteRule ^(.*)$ /drupal/$1 [L,QSA]

#url 's
RewriteCond %{REQUEST_URI} !^/drupal
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

The htaccess in drupals folder is just as normal, just uncommented RewriteBase /drupal.

I understand what the problem is, the files are redirected directly to where they are, not going through Drupals system, which becomes the case when clean urls are turned off. But this is the only version of a htaccess file that works, and I've tried several. If I rewrite the files to /drupal/index.php?q=$1 images in the stylesheet and the logo and other images like that aren't displayed.

Would appreciate any help!

The ultimate goal here is to get any request to the base domain (http://www.example.com) redirected the drupal subdir (http://www.example.com/drupal), correct? Why not just remap everything to the subdir and let Drupal handle the www. prefix and clean-url mapping?

RewriteCond %{REQUEST_URI} !^/drupal
RewriteRule ^(.*)$ /drupal/$1 [L,R=301]


Drupal core tries to update to current version Many sites on my server are running Drupal 7.23, I usually use Drush to update them without any issue. Eveything works fine with modules and themes but Core keeps installing 7.23 on itself.

The admin/reports/updates page display this :

Drupal Core 7.23
  Recommended version: 7.23
  Security update: 7.24
  Last version: 7.25

It obviously tries to update to the recommended version, which is in this case the current one (7.23).

I use the permissions guidelines given in the script on the bottom of this page. I tried to change the file owner, it is not working. We recently installed Nginx as a reverse proxy on our server but the problem still the same calling directly Apache.

I also have some sites running Drupal 7.24 and no issue when updating to 7.25.

Any clue on the origin of this issue ?

I found the solution, with the following command line.

drush pm-update drupal-7.25

I still do not understand why the regular update fails but this last command works fine.


Custom Content Pane Title I created a custom content pane, however, I'm having some issues trying to hide the title on the page and was wondering if anyone knew of a module for this?

Here's the quick breakdown:

I created a new custom content pane:

Above I have given the custom content pane no title, however, this is how it shows up:

I'd really like to make it look more descriptive.

If I add a title it will show on the variants > content page (image below), but unfortunately, it also shows up on the actual page as well.

Live page:

Any and all help would be greatly appreciated. Thank you!

Have a look at:

ctools_custom_content_type_admin_title

/**
 * Callback to provide the administrative title of the custom content.
 */
function ctools_custom_content_type_admin_title($subtype, $conf) {
  $settings = ctools_custom_content_type_get_conf(ctools_custom_content_type_content_type($subtype), $conf);

  $output = t('Custom');
  $title = !empty($settings['admin_title']) ? $settings['admin_title'] : $settings['title'];
  if ($title) {
    if ($settings['custom_type'] != 'fixed') {
      $output = t('Custom: @title', array('@title' => $title));
    }
    else {
      $output = $title;
    }
  }

  return $output;
}

If the admin title is used, and the custom content type is not set to 'fixed' (see ctools_custom_content_type_get_conf), it will use your user input admin title for admin display there.


Use images in pagination links I am using drupal 7 and i am trying to override the pager.inc function like this .

function bartik_pager_first($variables) {
  $text = '';
  $element = $variables['element'];
//  $parameters = $variables['parameters'];
  global $pager_page_array;
  $output = '';

  // If we are anywhere but the first page
  if ($pager_page_array[$element] > 0) {
    $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
  }

  return $output;
}

As you can see i am just trying to print the image for the text "first". But its just displaying like

How do i tell drupal that display it as html image rather then just text.

You have to override theme_pager_link() as well. The last line calls the l() function and you have to force it to render html.

Another possibility is to use css to theme the links


Remove SKU label from product reference select list Is there a way to remove/hide the SKU value in the product reference widget (select list)? Because we don't want to show the SKU value to the editors.

In a custom module (or theme) you could implement hook_field_widget_WIDGET_TYPE_form_alter() and alter the labels of the options (i.e., stored in the $element['#options'] variable). If I'm not mistaken your function would be mymodule_field_widget_options_select_form_alter(&$element, &$form_state, $context), where mymodule is your custom module (theme) name. Don't forget to check for which field you're altering the options, you can find this in $context['field']['field_name'].

If you don't want to write custom code, you could as an alternative use the Entity reference module in combination with Views. Hereby you can use the output generated by a view as an option list for the (entity) reference field (pointing to your product).


Slideshow of images which are not a field of node I have used FlexSlider module to create an image slider. It works perfectly. I create a content type, with image field, create several nodes of that type, and finally I create a View of that content type. In the Format of the View, I can choose the FlexSlider style, and I am done.

What I want is to use several large images, which are many (3.000) images, and instead of creating 3.000 nodes, I would like to have the images externally, in a folder and referenced by a table of its own, and do a Flexslider using the View that already have, with mimimum modifications. Is it possible to get the same effect but without using nodes? If I load the images into nodes using Feeds, it takes ages, and I have some problems, so decided to go with the images outside of the nodes. Maybe a SQL alter could do it?

I have solved the problem by using Lightbox2 module, which allows to render a Slideshow with no need of a View or configuring the images as fields of nodes.

You can see the solution with some code, in this other question and answer of mine. So this is a solution for someone looking for:

A gallery of many many images.
Slideshow with thumbnail.
Thumbnail + Medium image (detail of product, for example), with the Slideshow launched from the Medium image, no the thumbnails.

How to configure a Slideshow with thumbnails in modal window


Unit testig on multisite I am trying to simulate a multi-site environment in an integration test with phpunit. I know how to init a new database connection with Database::addConnectionInfo but how can I cleanly switch the database used by the current environment?

Database::setActiveConnection will only work for SQL queries but I would like to use the entity_type.manager service and the only way I found is to replace the database service in the container and call KernelTest::setUp. Switching back an forth between the databases is still pretty buggy and complex.

Any ideas?

"Unit testing" and "multi-site" are in direct conflict with each other. Multi-site is definitely an integration/functional testing concern.

What you can do in a unit test to help guarantee that things are working correctly for a multi-site setup is to unit test only the logic that is computing different results for each site in the multi-site setup. Use a @dataProvider to test the input for different sites in a multi-site setup.

The result of that logic should vary by the url.site cache context. You can assert the presence of that cache context in the X-Drupal-Cache-Contexts response header in your integration/functional test.

IOW:
- unit test for testing various inputs, with a @dataProvider
- functional test that asserts the presence of url.site cache context

Together, they guarantee things work correctly.


How to dynamic select options each webforms seperately? Currently I have a table of records webform (The node identifier of a webform) and a list of users, Associated with the webform table nid
The group has kept a list of users webform's (The node identifier of a webform).

The purpose is to be in accordance with a different view webform to fill a single page, you can automatically bring out the webfrom belong to fill a single page to view a list of users group, the following screen embedded in it, and you want to automate the dynamic select options each webforms seperately, That each webform node page has a list of  dynamic select options users group.

If the user fills again webform view to fill a single page, select a person of a certain list of users, and finally to be able to produce the data stored. To record the value webfrom submit sid and webform nid and selected personnel.

How do I make it?

I don't entirely understand your question, but I believe that you want to customize a webform based on the user currently logged in.

To do this you can use hook_form_alter.

All webform have an ID that starts webform_client_form_ so you check check for this, and then make any modification as necessary.

E.g:

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

    //drupal_set_message("Form ID is : " . $form_id);

    if(substr($form_id, 0, 20)=='webform_client_form_') {

        global $user;

        // make changes to form here

    }
}


node permission based on a cck user reference field I have a cck user reference field in a content type in drupal 6. I want only the user selected by that field can view the node content.

How can I achieve this?

Install the User Reference Access module - it directly addresses this requirement:

  This module works with CCK userreference fields and the node_access
  module to add additional grants to nodes.

  To enable userref_access on a node, edit the userreference field for
  the node type and check the "Use User Reference Access" box.

  Any users that are referenced by this field will be given view
  permissions for the node, all other useres will be denied access to
  the node.


How does a Webform able to differentiate among radio buttons, check boxes and Lists I am using webform module to build forms. Initially i created a simple form with few components like text-field, text-area, radios, check boxes , Drop down list and submitted it.

When i checked the database,  I found that the module is storing type "select" for the components radio, check boxes and lists in table name "webform_component". I want to know how can we differentiate them.

Please check the screenshot,

While creating the form i choose the following parameters

Gender ----> Radio

Range  ----> List

Hobbies----> Checkbox

But in the table it was shown as "select" for all the fields

Can anyone suggest the way to find out ?

the webform_component table also has an extra column you've cropped out.

It's SQL column help description is:

  Additional information unique to the display or processing of this
  component.

A select can simply be rendered many ways -- I believe the display settings for the "selectable options" used in rendering a radio, list or checkbox are in that column.


Is a custom module the best way to build out a Form with full custom AJAX? I have a project (problem) I've been thinking about for about a week now. When it was first presented to me it seemed to be a very easy solution, and frankly there are easy ways to accomplish this, but I don't necessarily like them. Let me lay this out though.

The Simple Problem

At its simplest this project is creating a simple (name, email, and one other field) form that will be available from any page of our site.

Let's Get Complicated

I want this form to be available on each page, but possibly tucked away with a call to action befitting our user base. On top of that I am not looking to just have a link to a Webform page, but an AJAX powered form so that my users do not lose their place in the site if they choose to submit their information.

So what's the ultimate problem?

I've looked into modules like Webform AJAX, but they don't allow the kind of fine grain AJAX control I want. I've done research into the Form API (Which, btw, if you have a great resource for understanding this better, please feel free to pass it along.), and it would appear that to accomplish everything I want to do with this simple form would require me to create a custom module.

Questions I have.

Is that right?
Am I way off base?
How much have I over-thought this project?

Thanks in advance.

Building custom module for mentioned requirements would make your work easy and dynamic. Dynamic in sense you can add more links if you publish any new page in future.
It would be great if you use ctools-modal with custom module. I was facing the same problem. I had wasted a week for finding better way to get link with ajax form.