a single field from reference entity causing memory error I have a field in my articles content type that is an entity reference to a people type. Editors can select the "author" from the list. This is all working great. We are using panels to display the article, so I have some view blocks to display some of the related information. When trying to display the author information, I get an out of memory error once I've included this one particular field. So, in narrowing it down, when creating the view, all fields from the referenced entity display fine if this field is not included. Once I add this field, the view preview gets the error as well. The strange thing is that this field is not a duplicate field from the article type. I tried changing the view format to show content instead of fields - same error. I also tried rendered entity - same error. I'm not sure what other steps I can use to track down and fix the issue with this one field.

Should anyone come across this, I had failed to mention that it was an image field. The problem what the image style that I had used. I have the imagecache_actions module for the aspect switcher functionality. Somehow the style I was using had the circular reference. I had to copy another style to that style in features in order to event edit the style. Then I was able to recreate the style properly and the problem is fully gone.


Unable to sort by term weight within multiple term reference I have two taxonomies, Menu and Menu Category. Menu has a term reference to Menu Category, allowing multiple selections.

I have a view that displays a Menu, and in this view I'm displaying the related Menu Categories - in the Multiple Field Settings for Menu Categories, I have the "Display all values in the same row" option unchecked.

The Menu Categories are sorted by weight, but in the view they are not being output in this order (I can't honestly say what order they are appearing in, perhaps by the order they were added as term references, but certainly not alphabetically or by id).

I've added a Menu Category to the sort criteria, but that doesn't have the desired effect (presumably because it's not looking within the Menu Categories).

I also tried adding a relationship to Menu Category from this view, but this doesn't seem to work either - although there are 3 options and I'm not sure which (if any) are correct:

Taxonomy term: Content using Menu Category

  Relate each Content with a Menu Category set to the term.

Taxonomy term: Menu Category (field_menu_categories)

  Appears in: taxonomy_term:menu.

Taxonomy term: Taxonomy term using Menu Categoies

  Relate each Taxonomy term with a Menu Categories set to the term.

Update: As requested, to clarify my view output, I'm expecting the Menu details including the list of Menu Categories, with this taxonomy sorted by the weight assigned to it.

On further looking at this issue, I decided to approach it from a different angle. Without any modifications to my view, which has no sort order defined, I installed and enabled the Taxonomy Term Reference module (https://www.drupal.org/project/term_reference_sortable).

Using the above module and setting my Menu Categories term reference to use this widget, I found the order I selected is reflected in my view.


remove existing spam comments I have a Drupal 7 site. This is a live site with both legitimate comments and spam comments. From what I can tell, most of the spam modules work when a comment is submitted, but don't go back and look at existing comments, comments added prior to the module being installed. I'm looking for a way to do this programmatically.

Views Bulk Operations has an "Unpublish comments containing keyword" operation.


How do you export forum topics from one drupal installation to another? I have tried to export a list of forum topics and/or containers from my development environment to production using features, strongarm, migrate, node_export and bulk_export. So far none have worked. Am I doing something wrong or is this not possible via contrib modules?

If your environments can communicate via rsync then use
drush sql-sync

Check the syntax www.drushcommands.com/drush-7x/sql/sql-sync to see how to pass a list of tables via the tables-list parameter.

else just use mysqldump.


link to profile in menu I am using the default profile as a "user dashboard" I have a main navigation link that needs to link to the users profile so is there a way to insert a dynamic link based on the current user? I need to add something like

user/{$GLOBALS['user']->uid}

If there anyway of accomplishing something like this?

You can use the link directly as /user. It also goes to the profile page which is similar to the /user/{$GLOBALS['user']->uid}
Now if you want user id also with it, e.g profile in edit mode (user/10/edit) then you need to add Menu Link module. It provides  you option to use Token to make the link dynamic for every user profile instead of static path.
Hope it will help.


"The specified file temporary://fileXXXXXX could not be copied" warning If i open my local website there is a indication like this.

  The specified file temporary://filel17IDM could not be copied, because
  the destination directory is not properly configured. This may be
  caused by a problem with file or directory permissions. More
  information is available in the system log.

how to get out of this?

The temporary directory set under Admin > Configuration > File System is incorrect or does not have write permissions. Typically for local dev (on Linux/OSX machines) this path can simply be /tmp. On Windows, I believe it is C:\temp.

See: Configuring the temporary directory


Display own unpublished nodes I tried creating a view where I display user's unpublished nodes.
The view works flawlessly for super user 1, but it doesn't work for authenticated users where no nodes are displayed though the authenticated user can directly access the unpublished node and edit it.
Things I tried:
1. Try different display formats (e.g. fields, full content)
2. Removed all kinds of filters
3. Removed all kinds of access rules for the view
4. Reviewed permissions:
  a. Administer content is unchecked for authenticated user
  b. View own unpublished content is checked for authenticated user
  c. create/edit/delete content permissions are set for authenticated user
  d. Bypass content access control unchecked for authenticated user

Is this normal or this is a views' bug?

UPDATE:
I posted my question on Drupal bug tracker. It seems that a module is causing the issue. https://www.drupal.org/node/2810077
I tried creating a new Drupal 8 installation with a view that shows unpublished content and now it displays all unpublished content regardless of user's permission...

Try view_unpublished module and check can you see unpublished nodes.

  Description: This module allows you to grant access for specific user
  roles to view unpublished nodes of a specific type. Access control is
  quite granular in this regard.

  Additionally, using this module does not require any modifications to
  your existing URL structure.


Upgrading to a development snapshot I currently use Drupal 7.0.

I am thinking that upgrading to 7.x-dev would resolve some performance issues I have.
Do you think that upgrading a production site to the development snapshot would break any possible database upgrade path?

It is safe to use the 7.x-1.x-dev version now. The updates happen incrementally, based on a number that is updated for every new update function.

It was only before the 7.x-1.x-beta releases, where upgrading was not supported (And apart from some bugs during the beta IIRC) for the -dev version.


How to implement a reputation based system with badges in Drupal similar to StackExchange sites? Earning badges on StackExchange is, well, fun. But aside from that it promotes quality interaction from users and helps weed out spam (I have never seen a spam post on the site).

I have a community website with about 500 active users, but the spammers are starting to become more prolific.

I would like a way to make the site more engaging while promoting the same quality of interactivity.

How would you recommend to put in a good reputation system, as well as a goal achievement system?

There's the User Points module and the User Badges module, though the 7.x version of User Badges is not suitable for production yet (as of June 4, 2012).

Thankfully, User Points integrates with the Rules module, which allows you to greatly customize the ways users gain (or possibly lose) points.

There's also a collection of contributed modules for userpoints of varying stability.  You can certainly set up some amazing stuff with these modules, but make sure to carefully test your implementation-- though the modules are well written and fairly stable, there's still a lot that can go wrong so make sure to verify everything works properly.


How to add a RSS Feed to a solr search view in drupal 7? I'm trying to add a rss feed to my website.
It has content indexed by a a solr search and somehow when I try to add a RSS feed it says:

  Style RSS Feed requires a row style but the row plugin is invalid.

Also in the edit view the following message is shown:

  Show: Missing style plugin

using drupal 7, solr, and views

Using a 'normal' view RSS 'page' can be created

How do I add the missing style plugin and where do I find this plugin?

as a temporary solution I created a new view with the same content added a rss feed to that. now I do have a rss feed but not on the page I want it to be.

I'll accept this answer until a better one shows up.


Getting rid of password_confirm labels in module In a module, the following generates unwanted labels for 'Password' and 'Password confirm':

$form['password'] = array(
  '#type' => 'password_confirm',
  '#maxlength' => 20,
  '#size' => 10,
);

It produces the following HTML:

  Password
  <input class="password-field form-text" type="password" id="edit-password-pass1" name="password[pass1]" size="10" maxlength="128" />

  Confirm password
  <input class="password-confirm form-text" type="password" id="edit-password-pass2" name="password[pass2]" size="10" maxlength="128" />

The object is to get rid of the text labels and replace them with images.  I have tried toggling '#title', '#title_display' and '#label_display' but nothing works.

Any ideas?

I agree with @Clive that it is not a good idea to remove those labels, but there is a way to make them invisible, without to remove them. Drupal 7 has a CSS class for that purpose: element-invisible.

The code I would write is similar to the following one.

function mymodule_form($form, &$form_state) {
  $form['password'] = array(
    '#type' => 'password_confirm',
    '#maxlength' => 20,
    '#size' => 10,
    '#process' => array('form_process_password_confirm', 'code_testing_process_password', 'user_form_process_password_confirm'),
  );

  return $form;
}

function mymodule_process_password($element) {
  $element['pass1']['#title'] =  '' . t('Password') . '';
  $element['pass2']['#title'] =  '' . t('Confirm password') . '';

  return $element;
}

The process functions I am using are the same used from the "password_confirm" form field, except the second one, which is my custom process function I use to make the label invisible.

You could also replace the reference to form_process_password_confirm() if you want to radically change the output for the form fields. The last process function I am using is the one that adds the JavaScript code which checks when the password entered in the two form fields is the same, among other things.


line break or second row for single record in view? I'm using views2 in Drupal 6. I have a view for a custom table. One of the column is called 'notes', which is a textarea. Most of the time it's blank, but sometimes not.

I would like to have it so that if there is a value in the notes column, instead of displaying it in the column, it would add a line break or another row underneath the normal values, like this:

+-------+-------+-------+-------+
| col 1 | col 2 | col 3 | col 4 |
+-------+-------+-------+-------+
| val 1 | val 2 | val 3 | val 4 |
+-------+-------+-------+-------+
| val 1 | val 2 | val 3 | val 4 |
| this is a note.               |
+-------+-------+-------+-------+
| val 1 | val 2 | val 3 | val 4 |
+-------+-------+-------+-------+

Is this possible to do with built-in views functionality, or is there a module that can accomplish this?

There is a module for Drupal 7 and Views 3.x called Views Secondary Row. Sadly, it's not available for Drupal 6 or Views 2.x.

A first-glance at the code of Views Secondary Row makes me think that a backport to Drupal 6 and Views 6.x-3.x might not be too difficult if you have some module-development experience (although I've never written modules to work with Views before, so I'm not sure how accurate that observation is). If you don't want to try your hand at it personally, you could put a feature request in the issue queue.


Cloned Seven/Bartik themes don't show up I copied bartik and seven theme from core/theme folder into the /theme folder.

I renamed both into xbartik and xseven.
I renamed all the files named bartik to xbartik and seven to xseven.
I did a find a replace in the info and theme files to the corresponding name change of xbartik and xseven.
Did a flush cache and it doesnt show up.

What else could I be missing in this process?

I renamed all the files named bartik to xbartik

When you say all the files, I hope you also did bartik.schema in the /config/schema folder.

  I did a find a replace in the info and theme files to the
  corresponding name change of xbartik and xseven.

You need to do this for all files, including files like bartik.schema, bartik.libraries.yml bartik.breakpoints.yml.


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

Comments in Drupal 7 are tied to Nodes. You could try the Reply module but it is still a dev project.

Usually though in situation like this though if a project needs some functionality that is built into Nodes in Drupal core I think it might be case where Nodes should really be used.


Views (Search API): Search taxonomy parent and display all children Problem

I have a country taxonomy field. The top level is continents then below that countries:

Asia
--China
--Thailand
Europe
--France
--Germany

I'm using search API (with solr backend) to index.
Views to display the results.
Views exposed filters to search.

How can I set-up the search, so a search on a parent term (e.g. Asia) displays all it's children (China, Thailand etc.)?

So Far

I think the relevant solution if you're not using Search API is described in this page:

Use views to display taxonomy children terms from parent

I think you have to add a contextual filter which sets the rules for taxonomy, however this doesn't seem to be an option in Search API. There are also no contrib modules which solve this problem.

Has anyone tackled this before?

There's a wonderful little checkbox in the Search API workflow tab which enables it.

Head to:

admin/config/search/search_api/index/*your solr server*/workflow

(You'll need to have created a server to get to this.)

And then tick the box "Index Hierarchy".

In callback options select the taxonomy field where you would like searching for the parent to include the child.


ckeditor - Two views with editable fields on the same page I have put two identical pane views (an original display along with a clone)  on the same page. I needed two copies because each view has its own set of exposed filters, so they can display different nodes side-by-side.

The views consist of multiple editable fields that seem to be identical comparing to the other view so they have even the same element IDs..

As a result, ckeditor which is the default wysiwyg editor only loads on the first view, giving me the following error on console:

Uncaught The editor instance "edit-field-e1-0-field-e1-und-0-value" is already attached to the provided element. ckeditor.js?o5iwm7:286

How can I prevent this? Is there a way to set different ids on cloned displays?

If I recreate the same display manually, would it be any difference? (its a huge display)

To counter this, I had to clone every field in the second display only to force Drupal to assign different element IDs to each one. Then I deleted the initial fields.

So

views-field views-field-field-e1

changed to

views-field views-field-field-e1-1

letting the Ckeditor to render the rich text editor on every instance.


How do I create an entity using the properties of another entity? I am currently working on a custom "quiz" like module in Drupal 7.  The way it works is as follows:  a site administrator creates a bunch of reading assignments, and associated questions that go with those readings (the reading might be a downloadable PDF, or a link to some online content).  I currently have an entity called "reading" which has a title, description, media type field (pdf or link), and a group of question text fields, where the admin can create an arbitrary number of questions.  Thus, a constructed reading entity might look like this:

========= READING ENTITY ===========
Title:       Some Great Paper
Description: This great paper was written by Joe Schmo, and it is great.
Media Type:  PDF
File Field:  /path/to/the/uploaded/file.pdf
Questions:
             What did Joe mean by 'Persistence is necessary?'
             How would you apply these ideas to your life?

Now, I am trying to create the "Assignment" entity.  This is an entity that an instructor would create by picking a reading from the pool of reading entities an administrator has created.  The assigned reading entity would look very similar to the reading entity, however it would have some additional fields.  For example, it would need an indicator that the student has submitted the answers, and a grade field for the instructor.  It would also need fields for instructor notes, and student answers.  Since there needs to be an attached answer and notes field for each of the questions, I also created an "AssignmentQA" entity.

Finally, there is a requirement that if an instructor creates an assignment, and later on an administrator updates the "Reading" entity (Say, changes questions, or the pdf file to be downloaded, etc..) that this change is NOT seen in already created assignments.  Thus, everything would need to be cloned.  I see the Assignment and AssignmentQA entities associated with the above reading as looking like this:

============== ASSIGNMENT ENTITY ===============
Title:       Some Great Paper    <--- cloned from the Reading entity
Description: This great paper... <--- cloned from the Reading entity
Media Type:  PDF                 <--- cloned from the reading entity
File Field:  /path/to...         <--- cloned from the reading entity
Instructor:  User reference to the instructor
Student:     User reference to the student
Status:      [Assigned, Completed, or Graded]
Notes:       General notes from the instructor to the student...
QAs:
             reference field to QA1
             reference field to QA2

============== ASSIGNMENTQA ENTITIES ==============
ID:          QA1
Question:    What did Joe mean by 'Persistence is necessary?' <--- Copied from Reading's Q1
Answer:      The student's answer to this question.
Notes:       Instructor's notes on this particular answer

ID:          QA2
Question:    How would you apply these ideas to your life? <--- Copied from Reading's Q2
Answer:      The student's answer to this question.
Notes:       Instructor's notes on this particular answer.

Of course those IDs for the AssignmentQA entities are pseudo-code used for clarity.

So with all that being said..

Does this sound like a reasonable approach?
Is there a better way to think about this/do this?
If it is reasonable, is there a way to pass a reading entity to the Assignment Entity so that I can properly construct an assignment from the reading data?
And, how do I go about cloning the pdf file field, such that the pdf file can't be deleted from the server if it is updated, but the old version has already been assigned to someone?  (e.g.- I'd like to use the updated PDF for any new assignments created, but keep the old one around for old assignments).

Does this sound like a reasonable approach?

You've put some thought into this, it doesn't sound unreasonable -- nor does it sound simple.

  Is there a better way to think about this/do this?

If your reading Questions are simply textareas great, if they're radio boxes and select widgets look into leveraging an existing "quiz" or form builder like: webform, webform_entity or the quiz module.

  If it is reasonable, is there a way to pass a reading entity to the Assignment Entity so that I can properly construct an assignment from the reading data?

I have cloned nodes before in Drupal 6/7, which isn't too hard. I think you need to really iron out a workflow for "if I make a reading -- I can create Assignment(s) and/or AssignmentQA entities". You could try creating this workflow logic for instructors using workflow, maestro or using a set of Rules.

If you try and just "I made a reading entity". You could always make a view that allows you to create a hook_menu() link to a new node edit form using a Reading Node as a menu argument -- then you could see the original node's fields easily for cloning.

  And, how do I go about cloning the pdf file field, such that the pdf file can't be deleted from the server if it is updated, but the old version has already been assigned to someone? (e.g.- I'd like to use the updated PDF for any new assignments created, but keep the old one around for old assignments).

In D7 the file_managed FAPI element allows you to set an "owner" module for the FID, I believe only that module may deem the file as 'deleted'. So using a custom FAPI override you could specify a module you control as the enforcer for this ruling. The D7 file_entity module is seeking to add views to track individual file usage of FIDs i'm not sure if it's ready for prime time usage.


Authenticated users can't view the front page I set node/4 as the front page on the Site Information screen.

This works for anonymous users, but authenticated users cannot access the front page (node/4).  Even if they manually type www.site.com, they are redirected to www.site.com/user/4.

Please help me out.

Building on Patrick Kenny's comment, I'd recommend looking for the 'URL redirects' page within your admin pages. (You will have this page if you've installed a module which supports URL redirects - 'Redirect' in D7, 'Path redirect' in D6.) Then see if any rule is defined there which'd redirect visitors from site.com/node/4 to site.com/user/4 .

If this module isn't doing this, odds are another one is, so as Patrick says start disabling contrib modules one by one.


How to make the help text of a content type field collapsible? I have built my Drupal 7 tennisclub-site so that a few users can maintain the content in it.

Most of these few are irregular users, that only come to maintain their part of the content a couple of times a year.
For these people it is important that they are led through the steps of lets say... creating a calendar item, using the field-helptext. So there is a helptext for the title, a helptext for the date(s) and a helptext for the body of the content type "calendar-item".

While very usefull to the infrequent user, these helptexts are quickly becomming annoying to regular users.
How do I make the helptexts collapsible and how do I set it's default state?
Which modules do I need for this to work?

Thanks in advance,

Tijs

Each form element in your input/edit form will be in a div with a unique id, and will have a child division with the 'description' class which contains the help text.

If you know which div's you wish to collapse, it can be done with javascript, following the model for Collapsible Blocks.


Two different front pages with different themes So I have the following problem. I created an entry page with module front that has two links. To categoryA and categoryB. Now I want these two categories to have different front pages with different themes.

Any ideas on how I can achieve that?

Have you tried the ThemeKey module?

  ThemeKey allows you to define simple or sophisticated theme-switching
  rules which allow automatic selection of a theme depending on current
  path, taxonomy terms, language, node-type, and many, many other
  properties. It can also be easily extended to support additional
  properties exposed by other modules.


Location Module and Search api I am using the Location Module to add a location to a field on a content type
I am then using Views and Search Api to create an index and a view of this content type.
The problem I have is that I cant find any way to get the data from the location to the view. At the bottom of the search index page I can add other entities such as users that are linked to this node but not the Location this is the same for Relationships section in the view.

This was a compatibility issue with the Location module moving over to geofield
module allowed me to add the coordinates to the search api index


Field contains list and values of it are shown in one symbol I'm developing a drupal module and there's a problem. I need to make a content type with some fields and one of them should have list with string values. But when I try to create content and choose new content type I created, I see list and there are values contains first symbol of the string that I need.

coursebook.info.yml

name: Course Book
description: Course book
type: module
core: 8.x
package: Course book module

field.storage.node.field_disciplines.yml

langcode: en
dependencies:
  enforced:
    module:
    - coursebook
  module:
  - node
id: node.field_disciplines
field_name: field_disciplines
entity_type: node
type: list_string
settings:
  allowed_values: { "1":'A', "2":'Bb', "3":'Cccc'}
  max_length: 1000
module: core
locked: false
cardinality: 100

field.field.node.coursebook.field_disciplines.yml

langcode: en
dependencies:
  config:
  - field.storage.node.field_disciplines
  - node.type.coursebook
id: node.coursebook.field_disciplines
field_name: field_disciplines
entity_type: node
bundle: coursebook
label: 'disciplines'
description: 'Type disciplines here'
required: false
default_value: 'example'
settings: { }
field_type: list_string

core.entity_view_display.node.coursebook.default.yml

langcode: en
status: true
dependencies:
  config:
  - field.field.node.coursebook.field_year
  - field.field.node.coursebook.field_semester
  - node.type.coursebook
id: node.coursebook.default
targetEntityType: node
bundle: coursebook
mode: default
content:
  field_year:
    label: hidden
    type: string
    weight: 0
    settings: {  }
    third_party_settings: {  }
  field_semester:
    label: hidden
    type: string
    weight: 1
    settings: {  }
    third_party_settings: {  }
  field_disciplines:
    label: hidden
    type: string
    weight: 2
    settings: {  }
    third_party_settings: {  }

core.entity_form_display.node.coursebook.default.yml

langcode: en
status: true
dependencies:
  config:
  - field.field.node.coursebook.field_year
  - field.field.node.coursebook.field_semester
  - node.type.coursebook
id: node.coursebook.default
targetEntityType: node
bundle: coursebook
mode: default
content:
  field_year:
    type: string_textfield
    weight: 0
    settings:
      size: 30
      placeholder: 'example'
    third_party_settings: {  }
  field_semester:
    type: string_textfield
    weight: 1
    settings:
      size: 30
      placeholder: 'example'
    third_party_settings: {  }
  field_disciplines:
    type: string_textfield
    weight: 2
    settings:
      size: 30
      placeholder: 'example'
    third_party_settings: {  }
hidden: { }

And what I see -
But i shuold see this list:

allowed_values: { "1":'A', "2":'Bb', "3":'Cccc'}

There are only files that describe problem field. I hope you understand my problem. I develop my module using this manual: https://medium.com/touch4it/custom-content-type-with-custom-fields-for-your-drupal-8-module-9478fd018f76

You need to have the allowed values settings in the following format:

allowed_values:
  -
    value: '1'
    label: A
  -
    value: '2'
    label: 'Bb'
  -
    value: '3'
    label: Ccccc

The quotes don't matter for single word strings. I hope this helps.


Create a percentage discount coupon with a maximum value Need to have a coupon that follows this basic logic:

IF (Commerce % Coupon Granted amount > Max Value) THEN
    Commerce % Coupon amount = Max Value
ELSE
    Commerce % Coupon amount = % of ORDER

For example:

10% with a max of $100.

  Order value = 500, Discount = 50 (10% of 500)
  Order value = 1000, Discount = 100 (10% of 1000)
  Order value = 1500, Discount = 100 (flat 100)

If you're using the latest version of Commerce Discount and Commerce Coupon, you can accomplish this with just two rules connected to a single coupon code.

Create a Coupon Code by going to Admin→Store→Coupons->Create Coupon Code. Save it.
Create a new Discount (Admin→Store->Discounts->Create). Set it to Order Discount and add a Total amount condition. Set the condition to less than and the amount to 2000. Set the percentage discount as you desire. Finally, add the coupon code from step 1 to this discount and save it.
Create a another Discount. Set it to Order Discount and add a Total amount condition. Set the condition to greater than or equal to and the amount to 2000. Set the flat discount as you desire. Finally, add the coupon code from step 1 to this discount and save it.

Now, when a customer checks out, the coupon will attempt to apply both discounts, but because of the condition, only one will apply: $200 if the order is $2000 or over, and 10% if the order is $1999.99 and under.


drupal_set_message on node edit page shows twice with theme hook I want to display a value of a field which the user has no access to in a dsm when the user edits the page. The dsm is showing up after saving the node, and while that's fine (I'd even consider it a feature) it's showing the before-edit value of the node.

I believe I've run into this problem but there doesn't seem to be an easy fix. Here's a look at the template.php function.

function themename_form_vakature_node_form_alter(&$form){
    if(isset($form['#node']->field_vacature_scheduled_for_unp)){
        if($form['#node']->field_vacature_scheduled_for_unp['und'][0]['value']){
            $expirydate = date("F j Y",$form['#node']->field_unpublish_date['und'][0]['value']);

            if($form['#node']->field_unpublish_date['und'][0]['value'] < time()){
                drupal_set_message(t("This vacature has expired."),'status',FALSE);
            }
            else{
                drupal_set_message(t("This vacature will expire at: ").$expirydate,'status',FALSE);
            }
        }
    }
}

Basically, the message displayed on the edit page is repeated after a save. I need it to either not repeat or show the correct updated information.

Form alter changes the form when it's being built for display.

If you want to use the value on the node after update, use a hook like

hook_node_presave or
hook_node_update

instead.

To tweak your code snippet, something like:

/**
 * Implements hook_node_presave
 */
function mymodule_node_presave($node){
  if ($items = field_get_items('node', $node, 'field_vacature_scheduled_for_unp')) {
    $vacature = reset($items); // Use first field item value
    $expirydate = date("F j Y", $vacature['value']);
    $items = field_get_items('node', $node, 'field_unpublish_date')
    $unpublish = reset($items); // Use first field value
    if ($unpublish['value'] < time()) {
      drupal_set_message(t("This vacature has expired."), 'status', FALSE);
    }
    else{
      drupal_set_message(t("This vacature will expire at: "). $expirydate, 'status', FALSE);
    }
  }
}


How to prepend a Views query with another query? Due to a configuration problem at my host, I'd like to execute the query "SET optimizer_search_depth=0;" in the same DB session as a specific Views query.  I looked into hook_views_query_alter() and hook_views_pre_execute(), but in both cases the query is only available as a Query object.

I think I need some way to modify the raw query string before it's executed, but (presumably) after it's built.  Is this possible?

Why do you think you need to alter the query itself? You literally said you needed to set a …session value.

You can issue any query prior to the views query on that page load to achieve the desired affect. Eg db_query('set mysql_max_group_concat=5;');

If you want to so it in the views lifecycle you could use any hook_views_* api call which states it runs prior to query execution. Look at the views api docs.

Or you could likely use hook_page_build  for all its worth. Or hook_init ... whatever suits your needs.


some node image missing after node convert batch I have convert 50,000 nodes from one content type to another and mapping each and every fields. but after batch complete, some images migrate but some not. how i will fix this ? am i run migrate again ?

Are you migrate your content from D6 to D7? if yes, Then Migrate Fields page is divided into 3 sections:

Available fields

Converted fields

Unavailable fields

you can check the status here. May be it'll helpful to you.


How to use HTML in a webform component's title? We have a checkbox which's title should have HTML () but its rendered as text rather than HTML.

How to use HTML in a webform component's title?

At first, I misread your question and created Issue #3036393: Allow basic HTML markup in element titles.

Checkboxes do support HTML markup.

The below YAML…

checkbox:
  '#type': checkbox
  '#title': checkboxsup
checkboxes:
  '#type': checkboxes
  '#title': checkboxes
  '#options':
    one: onesup
    two: twosup

…renders via Bartik as…

If you can replicate and document this issue, please create a ticket on Drupal.org.


Menu alter for a particular content type I am trying to add a custom access callback for the node edit page for a particular content type.

I am using alterRoutes function to change the access callback but I am unable to get the node type in this function.

Am I missing something obvious?

There are o node type specific edit routes, only one. You'd have to alter that and then in your access callback, decide if it is your node type or not.

But, why don't you just implement hook_node_access() and check for the update operation? That allows you to control access to that page and also any edit operation elsewhere on th system, on whatever condition that you want.


Post the same menu as two different blocks? I have a menu called main-menu.  I want to post it twice as a block: one block with a main-menu in the header, and one block with a main-menu in the footer.  But Drupal 7 will not allow it.  Drupal 7 only allows me to post the block once...either in the header or in the footer.

Is there another way?  If not, I will use Javascript to clone the entire main-menu html node and append to footer node.

The Menu Block module will do this.

  So… have you ever used the Main and Secondary menu links feature on your theme and wondered “how the hell do I display any menu items deeper than that?”

  Well, that’s what this module does. It provides configurable blocks of menu trees starting with any level of any menu. And more!


Views: Add class to body based on Views In Drupal, every Views page has a class that is stored in $css_name (inside views-view.tpl.php).

Is there are any way to get this class to appear in the body class of the page?

Ideally, I would like to prefix it with page- (So views-index, would become page-views-index). I would also like to do it without install extra modules.

Two simple ways I might approach this:

Context Module
jQuery

1) Context Module: create a new context where Condition is "Views" (select the appropriate view) and the Reaction is "Theme HTML" (add the class you want to display in the body there).

Cons: the class is not dynamic, unfortunately. Or at least I have not investigated any way to make dynamically name the class (i.e. page-[node:field_field_yourfieldvalue]). Because of this, you will most likely need to create a new context for each variation if you choose this approach.

2) jQuery: if you want to get the classes in views and add an altered version of these classes to the body tag, then you could use some javascript to pull that off. Something to the effect of this might work:

var myClasses = $(.view-name).attr('class');

$('body').addClass(myClasses);

Something like that, just cleaned up. Hope that helps :)


How to open file in new tab instead of download when submitting form? The code below downloads the current file, I need it to open the file in a new tab, what needs to be added in order to do so?

public function submitForm(array &$form, FormStateInterface $form_state) {
     $filename = '/var/www/html/web/modules/custom/custom_module/sample.pdf';
     $response = new BinaryFileResponse($filename);
     $response->setContentDisposition(
          ResponseHeaderBag::DISPOSITION_ATTACHMENT,
          'sample.pdf'
     );
     $form_state->setResponse($response);

As @clive points out, this cannot be done on the server side. Check this post for a javascript based solution. You need to attach the javascript to your form during build. See below for an example of form build with a javascript attached to the submit element:

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
  // Assuming you are extending core \Drupal\Core\Form\FormBase class
  // and prior the lines below you built your form elements.
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this->t('Download file'),
    '#button_type' => 'primary',
    '#attached' => [
      'library' => 'your_module/submitToNewTab'
    ]
  ];

  return $form;
}


Taxonomy panel page visibility problem I have a visibility problem.
I have a taxonomy/term page managed with panels. There are 2 panel pane who display 2 views.
The problem is that I [the admin..] can see the page correctly but all the other users see nothing except a block I putted on top of panel pane for test.

I read the markup and I can see the panel but not the panel panes. This panel panes have no visibility rule and the views inside it have the default Access rule.

How can I find where is the issue?
Why only the user 'admin' can see this pages?

For sure this is related to permission:

A few pointers to help you debug:

Please check the permission of the components components you are trying to display through views. For example, a field is related to displaying an uploaded video. Anonymous users might ot be having permission to view it, though have the permission to view, but still they will not be able to access the stuff. So try to figure out what modules are responsible for the field you display through view, and then check the permissions coming from that module.

Actually this will be the only one that looks most probable to me. hope this helps.


Set a theme for a single content types edit page How do you set the theme for the edit page for just one content type on your site?  I am using bootstrap for non-admin pages and using the default seven for the admin pages. So basically I need to override the admin theme of seven with the bootstrap theme, but only for one content type.

Any help is much appreciated.

Using hook_menu_alter you can override even the theme a path uses.

function hook_menu_alter( &$items)
{
    $items['path']['theme callback'] = 'variable_get';
    $items['path']['theme arguments'] = array('theme_default');
}

like this you set the theme for that path to whatever the user theme is, even for admins.


Inserting search terms into a search input in Drupal 7 When using Drupal 7, how do I print the current search terms into a search form in a block?

In Drupal 6, I used something like this in my template.php:

$vars['search_keys'] = search_get_keys();

Then, in search-theme-form.tpl.php I had:

<input type="text" value="<?php print $search_keys; ?> name="search_theme_form" id="edit-search-theme-form-1">

But search_get_keys doesn't exist in Drupal 7, so I can't use this method.

Using arg(2) is the only method I've come up with, but that seems a little hacky, because it will break if the URL ever changes.

If you're using Apache Solr (http://drupal.org/project/apachesolr) you can use

$query->getParam("q")

in your search-result.tpl.php template.

Otherwise, you can use the slightly modified version of the function above:

function get_current_search_terms() {
// only do this once per request
static $return;
    if (!isset($return)) {
        // extract keys from path
        $path = explode('/', $_GET['q'], 3);
        // only if the path is search (if you have a different search url, please modify)
        if(count($path) == 3 && $path[0]=="search") {
            $return = $path[2];
        } else {
            $keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys'];
            $return = $keys;
        }
    }
    return $return;
}

edit: no need for check_plain here


Delete directory from private folder programatically? I'm using D8, and am writing a cron task to remove old backups from my private files directory. The backups are generated in private://db_backups/date-of-backups/backup.gz. The following code is properly deleting the actual backup files, but it is not removing the parent date directory. I am not receiving any errors in the drupal or server logs, so I'm a bit lost as to what's causing the failure.

function custom_changes_cron() {
    drupal_set_message(t('Custom cron function has run.'), 'status');
    $private_path = PrivateStream::basePath();
    $interval = strtotime('-430 hours');
    foreach(glob($private_path . '/backup_db/*' , GLOB_ONLYDIR) as $folder) {
        if (filemtime($folder) <= $interval ) {
            $files = glob("$folder/*"); // get all file names
            foreach($files as $file){ // iterate files
              if(is_file($file))
              unlink($file); // delete file
            }

            // Have tried both of the following
            rm_dir($folder);
            drupal_rmdir($folder);
        }
    }
}

Note that glob('*') ignores all hidden files by default. This means it does not return files that start with a dot (e.g. .file).  If you want to match those files too, you can use {,.}*  as the pattern with the GLOB_BRACE flag. This will include the special cases . and .. so you need to exclude those by using {,.}[!.,!..]*.

So in summary, try the following:

$files = glob("$folder/" . '{,.}[!.,!..]*',GLOB_MARK|GLOB_BRACE);

As a sidenote: you mention you tried using rm_dir. I assume you mean rmdir?


How do I implement hook_form_alter() in a module? I am trying to alter a form for the Question content type, whose ID is node-question-form.
I set up a module and tried to implement hook_FORM_ID_alter(), but it's not invoked. Even the simplest implementation as the following is not working.
function constellator_form_alter(&$form, &$form_state, $form_id) {
  echo "alter the form";
  exit;
}

I have been stuck with this since this morning. Nothing is working for me.

Here is a working example I have pulled from a project and altered to have your module name.

Add this at the top of your .module file:

use Drupal\Core\Form\FormStateInterface;

Then copy this in

/**
 * Implements hook_form_alter().
 */
function constellator_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Adding custom validation for the welcome page type field.
  if ($form_id == 'node_article_edit_form' || $form_id == 'node_article_form') {
    // Do some stuff.
  }
}

I think most likely what you aren't doing is clearing the Drupal cache to register the hook.  You can click on "clear all caches".  Or better yet, install the drush command line utility and use "drush cr".


Automatically fill in the subject line of contact form Is there a way to automatically fill in fields in Drupal 8 Contact forms, for example by passing the value in the URL? E.g.

/contact/myform?subject=Subject%20line

If Drupal doesn't have this built-in, does anyone know of a javascript plugin that will do this?

There isn't a built-in way to do this with the contact entity form. The prepopulate module looks like it would be covered under this scenario, but it doesn't work on contact forms.

As an alternative, a simple form alter with a custom module could do this on the back end, or front end, with a hook_form_alter() invocation.

The backend solution could alter the default form value:

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  // Set the default subject based off the subject query param.
  $default_subject = \Drupal::request()->query->get('subject');
  $form['subject']['widget'][0]['value']['#default_value'] = $default_subject;
}

Or the frontend solution can attach a custom JS file:

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  // Assuming mymodule has defined a drupal.mymodule library
  // within mymodule.libraries.yml
  $form['#attached']['library'][] = 'mymodule/drupal.mymodule';
}

Then have the attached JS attach to a Drupal behavior:

(function ($, Drupal, drupalSettings) {

  // Attach a drupal behavior that uses jQuery to alter the form value.
  Drupal.behaviors.mymodule = {
    attach: function () {
      var subject = '';
      // @TODO: parse location.search for the subject query param.
      $('#edit-subject-0-value').val(subject);
    }
  };

})(jQuery, Drupal, drupalSettings);


form_set_error not showing error message on webform I have created my own module and when i try to use form_set_error all im getting is the red border around the form input but no error message.

here is my code

function dd_alert_register_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id === 'webform_client_form_123'){
        $form['#validate'][]='dd_alert_register_form_validate';
    }
}

function dd_alert_register_form_validate($form,&$form_state)
{
    //where "phone" is field name of webform phone field
    $email = $form_state['values']['submitted']['email_address'];

    if ((bool) db_select('users')->fields('users', array('uid'))->condition('mail', db_like($email), 'LIKE')->range(0, 1)->execute()->fetchField()) {
        form_set_error('submitted][email_address',t('The e-mail address is already registered'));
        return $form;
    }
    // Then use regular expression to validate it.
    // In above example i have check if phonefield is empty or not.
}

I think it could also happen if $messages haven't printed in the page.tpl.php in your theme.

Is the <?php print $messages; ?> included in your page.tpl.php file?

Check this line in your page template. You might have missed it.

Hope it will help you!


Why my hook_menu does not work? I have this code in the module cleanetica_advanced.

function cleanetica_advanced_menu() {

    $items['ajax/content/%'] = array(
      'page callback' => 'cleanetica_advanced_ajax_load',
      'page arguments' => array(2),
      'title' => 'Ajax content load',
      'access arguments' => array('access content'),
      'type' => MENU_CALLBACK
    );

    $items['ajax/validate/form/%'] = array(
      'page callback' => 'cleanetica_advanced_ajax_validate_form',
      'page arguments' => array(3),
      'title' => 'Ajax validate form',
      'access arguments' => array('access content'),
      'type' => MENU_CALLBACK
    );

    $items['user'] = array(
       'title' => 'blogs',
       'description' => 'Listing of blogs.',
       #'page callback' => 'blog_page',
       'access arguments' => array('access content'),
       'type' => MENU_DEFAULT_LOCAL_TASK
     );

    return $items;
}

For some reason the item "blogs" (which I created for testing only, there are no blogs in our site) does not show in the tabs of the page /users. I need to show it in the /users tabs. What is my error?

I checked that cleanetica_advanced module is loaded by inserting some nonsense in the .module file and seeing that the site ceases to work with an error message. (Then I removed the nonsense.)

By the way, does user in $items['user'] refer to the page where the menu should be shown or to the ID of the menu item itself?

"user" is a path already used by the User module; if your module is not executed after the User module (i.e. you are not altering the order hooks are executed), the menu item of the User module takes the precedence. (That is also the wrong way to alter the menu item defined from another module, but your purpose is not that.)

  // Registration and login pages.
  $items['user'] = array(
    'title' => 'User account',
    'title callback' => 'user_menu_title',
    'page callback' => 'user_page',
    'access callback' => TRUE,
    'file' => 'user.pages.inc',
    'weight' => -10,
    'menu_name' => 'user-menu',
  );

If you want to define a menu tab for each user account, as I think, the definition of your menu item should be similar to this, used from the User module.

  $items['user/%user/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_profile_form', 1),
    'access callback' => 'user_edit_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'file' => 'user.pages.inc',
  );

For example, something similar to the following would work.

  $items['user/%user/edit'] = array(
    'title' => 'Blogs',
    'description' => 'Listing of blogs.',
    'page callback' => 'cleanetica_advanced_blog_page',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_LOCAL_TASK,
  );

The page callback receives an argument: the user object for the user account. It will be called from Drupal as cleanetica_advanced_blog_page($account).
Every function implemented by a module needs to be prefixed by its short name.
The menu type is MENU_LOCAL_TASK since there is already a MENU_DEFAULT_LOCAL_TASK menu item, and there cannot be two MENU_DEFAULT_LOCAL_TASK; the other tab is also the tab showing the details for the user account, and it is better to keep that as default tab.

If you want to show a list of blog posts global for all the users, then you need to change the path from user, or user/%user/edit, to (for example) blogs. Adding it as tab of the user tab doesn't make any sense, since the page would list content, not a list of users; it would be also shown together user/login, user/register, and it doesn't make sense to show a list of blog posts to who is registering/logging in.


Footer links - menu, UL or text What is the best way to enter footer links (horizontally)? I was thinking a Menu would be best but this causes limitations around what content goes in the links (eg. cannot have images or non hyperlinked text). While looking at another drupal site I noticed that the footer links are just regular content (not even in a list) ...

What is the best way? And how would you go about deciding how to do it?

Instead of seeing the footer as a single entity you can consider it as different blocks of which the links would be a part.

So you would have a region defined as footer and add blocks to that region. One block would be the menu and could have another for the static text and may be another one for the images. and arrange the same in the order you want.

In this way the links would be managed through the menu and the rest of the things through the respective blocks.

If you are sure that the content is going to be static through out the site then it would be better to put the same in the page.tpl file.


New Drupal 8 install, homepage works, all other pages throwing a 404 I have a server that houses my personal website (in the root folder.) Let's call it me.com. In the root I have: me.com files, a /dir/ called "me2." In /me2/ I have my drupal 8 install for a new site. Installed fine. Logged in, can access homepage. Every other link I click goes to a 404. I am not sure why this is happening.

*Edit: "me.com" site is Wordpress.

The problem may be that you don't have the .htaccess file on the root of your Drupal 8 website.


Customize Login Widget (set Default values in login input fileds) I added the login widget block to a page

I want to set the default value text "username" and "password" to the input fields.

It currently looks like 1. I want it to look like 2

There are a couple modules for this (quotes included are from their project pages):

In Field Labels:

  ... creates integration with the In-Field Labels jQuery Plugin.

Compact Forms:

  ... presents text fields for selected forms in a more compact fashion using jQuery.

  The form item/element fields are overlaid with their respective labels. When the user focuses a field the label fades away nicely, and if the field is left empty the label fades back in again.

  By default, only the user login block is switched to compact style, but the behavior can be added to any form by adding the corresponding CSS ids to the Compact Forms configuration.

  Degrades back to the original form when JavaScript is switched off.
  Fields like textareas and checkboxes are currently not affected.
  Inspired by A List Apart.


Deleting migrate module tables post migration We did a massive migration a while back, several hundred thousand rows. Needless to say we now have a bunch of migrate tables that we could do without.

I've disabled the migrate modules but before I dropped the tables (or should I truncate?) I wanted to make doubly sure that this will have no affect on anything.

Thanks in advance.

So, I deleted the tables (actually truncated them) on my dev server and there have been no side effects that I have noticed, so will try deleting the tables in their entirely. The migrate tables made up around 600mb in a dump.


How to easily find whether the contibuted modules have been updated or not? I am trying to upgrade my project form D6 to D7. I have used several contributed modules in my porject.

I am aware that I should check availability of all the contributed modules in version 7 before starting upgrade process.

In this case I need to check every independent contributed modules seperately whether it is available or not..

My question is:

  Is there any other easy way to check availability of all the
  contributed modules via programatically or any other modules to do
  this...

BTW : Not using drush...

If you are going to attempt an upgrade from D6 to D7, you really should consider using Drush.  Really strongly.  The Drush Site Upgrade command will save you a lot of time, and as a bonus, it will tell you the upgrade status of your D6 modules, and will recommend alternate modules for some modules with no upgrade path, but for which alternatives exist.

If you really don't want to use Drush, you can use the Upgrade Status module.  It also has an upgrade assist block that will help you walk through the upgrade process manually.


Creating multiple image crops with each instance of an image upload Can anyone tell me if there is a way to define multiple image sizes and create those images sizes each time an original image is uploaded?

I've been using imagecache but unless I'm wrong, it doesn't help when you want to create multiple images of various sizes when an original is uploaded.

Can anyone help?

You are using imagecache. Here you can create different type of image styles. And you can use below code for display multiple images of various sizes of an original uploaded image.

 $style = 'thumbnail_200_by_200';
 $image_uri = 'public://image_name.jpg';
 $img_url = image_style_url($style, $image_uri);

 <img src="<?php echo $img_url;?>"/>


Must at least one bundle have the same name as the entity in hook_entity_info()? I'm working with hook_entity_info, and I'm defining an entity which will have multiple bundles.

Do I need to define a bundle which has the same name as the entity, or will the base entity become entirely "abstract" once I define entity bundles?

In the below piece of code, I've defined a setting entity which has the bundle generic. Should generic really be called setting, or can i completely regard the entity as an "abstract" concept?

function settings_entity_info() {
  $info['setting'] = array(
    'access callback' => 'settings_entity_access',
    'admin ui' => array(
      'path' => 'admin/structure/settings',
      'controller class' => 'EntityOperationsDefaultAdminUIController',
    ),
    'base table' => 'setting',
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    'bundles' => array(
      'generic' => array(
        'label' => t('Generic Setting'),
        'admin' => array(
          'path' => 'admin/structure/settings/generic',
        ),
      ),
    ),

No, it's not required. It's not necessary to have a bundle whose machine name is the same machine name used for the entity type. And no, defining bundles doesn't make the entity more abstract in any way.

See, for example, node_entity_info(), where none of the content types (which are node bundles) is called node. Vice versa, in user_entity_info() the only bundle is user.
What you can gather from the implementations of hook_entity_info() done from Drupal core modules is that entities with a single bundle use the same machine name for the bundle and the entity. That is not mandatory, though.

What Drupal assumes is that, if hook_entity_info() doesn't define any bundle, the entity has a single bundle named after the entity type. See entity_get_info().

    // If no bundle key is provided, assume a single bundle, named after
    // the entity type.
    if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
      $entity_info[$name]['bundles'] = array(
        $name => array(
          'label' => $entity_info[$name]['label'],
        ),
      );
    }


How to create a View displaying the list of files attached to a page? I have added a file-field to my Page content type and activated the description field. Multiple files are allowed.

I want to create a block (with Views) that displays the list of files (descriptions with links) attached to a given page.

I have tried 2 approaches:

In views I have added a relationship with files, but the description is not accessible from the list of fields provided (filename, size, extension, but no description)
Create a new display (in addition to default and Teaser ) with the Content:Files field, it displays the list nicely BUT it shows the title and I can't see any option to disable it.

If someone has an idea that would be great! Thanks a lot.

If this is for Drupal 7, a solution I found was using Rewrite Results. Create a view showing Content of type Page which displays an unformatted list of fields. Within the View, under fields add your File Field. In the settings for the field set the Formatter to URL to file, remove the label and then under Rewrite Results tick "Rewrite the output of this field". Within this section you have access to the files description field so you can enter something like

[field_files-description]

Which will output the description as a link to your file.


Closing MySql Connection in Drupal7 How can I explicitly close a MySql Connection in Drupal 7?
I have a requirement of inserting back to rows to a DB table in Drupal..
I tried using db_insert/db_update and db_query.. In both cases I got the error Max number of SQL connections reached..
I am speculating that Drupal is maintaining these connections one per query and not closing them..
Hence I need to know if there is any way I can do it explicitly.

The specific function you are looking for in the database abstraction API is db_close() but you may be able to solve your problem through another route by increasing your max connections.

See this earlier thread on drupal.stackexchange for guidance on increasing max_connections. You might also be having a problem with slow / stalled queries that are trying up limited query slots, this thread offers advice on how to debug.


Boosting by changing bias of ApacheSOLR has no effect I am trying to understand the content-biasing. Somehow it has no effect on our installation.

Stepping through the code learns me that the query-string did change: the modified boost values like &bq=type:audio^1.0 show up, but have no effect on the search-results' sort-ordering or the $result["score"] value. the score remains exactly the same, no matter how high or low a bias is set.

Could it be cached somewhere on the solr server? (clear cache has no effect, code does not hint at caching it). Is this a known bug? Or an issue with the schema.xml?

Update:
Enabling debugQuery=on shows me an explain:

1.7849035 = (MATCH) fieldWeight(body:assen in 1952), product of:
  1.0 = tf(termFreq(body:assen)=1)
  4.0797796 = idf(docFreq=900, maxDocs=19600)
  0.4375 = fieldNorm(field=body, doc=1952)
","eskrkz/node/4622":"
1.1041226 = (MATCH) fieldWeight(body:assen in 1682), product of:
  1.7320508 = tf(termFreq(body:assen)=3)
  4.0797796 = idf(docFreq=900, maxDocs=19600)
  0.15625 = fieldNorm(field=body, doc=1682)
","eskrkz/node/8881":"

The field=body worries me. Why does it only search in body? Why not just any text? And why

An example querystring:

&fl=id%2Cnid%2Ctitle%2Ccomment_count%2Ctype%2Ccreated%2Cchanged%2Cscore%2Cpath%2Curl%2Cuid%2Cname&rows=10&facet=true&facet.mincount=1&facet.sort=true&facet.field=type&facet.limit=20&qf=body%5E40&qf=ts_vid_2_names%5E0.5&qf=tags_h2_h3%5E3.0&qf=taxonomy_names%5E0.5&qf=ts_vid_3_names%5E0.5&qf=title%5E5.0&qf=ts_vid_1_names%5E8.0&qf=tags_inline%5E1.0&bq=type%3Aimage%5E0.1&bq=type%3Aaudio%5E1.0&bq=type%3Adoc%5E0.1&bq=type%3Adossier%5E8.0&bq=type%3Aarticle%5E13.0&bq=type%3Apage%5E2.0&bq=type%3Aprogram%5E8.0&bq=type%3Asubsite%5E8.0&bq=type%3Avideo%5E0.3&start=0&wt=json&json.nl=map&q=FOO"

Turns out the solrconfig.xml for Drupal was not properly installed on the SOLR server. Which made it unable to parse the querystring properl with DisMax.


In node add, how to upload file using image from clipboard How can I paste image from clipboard and save into image_field ?

You could try the FileField Sources module. It provides quite a few additional options to upload files.

  Re-use files by an auto-complete textfield
  Attach server-side files uploaded via FTP
  Transfer files from a remote server (cURL required)
  Paste a file directly from the clipboard (Drupal 7 only)
  Select existing files through the IMCE file browser


How to prevent bots to enter specific pages on my site by a capture On my Drupal 7 site I have some pages that should not be entered by bots like the google bot or any other bot. All this pages are under a specific path like:

www.example.com/xyz/*

I have configured my robots.txt to prevent all bots to enter xyz/* but I would like to add a higher obstacle. I thought, for example, about a capture.

I there a way in Drupal 7 to restrict access to all pages that have an specific path by a capture or does anybody have a better idea how to achieve my goal?

It sounds like you want to guard against robots that ignore robots.txt. Or possibly against spambots that are trying to exploit your comments section. I think the easiest way is to not allow anonymous users access to the page. Then, if you protect the login page with captcha, you should be able to keep any bots where you want them.

You will need the Content Access module and the Captcha module.


Change field settings for text field from plain to formatted while data exists anyone know of a quick example of how to change the field settings for a text area (plain) to formatted and set the input formatter (or maybe it will use default)? Will this require a resave of all the data or can it just be changed for the entity type? I currently have a lot of existing data on this site.

The field is currently stored as the type string, Text (plain). I need to change it to text_long, Text (formatted, long).

Thanks

Attention for Drupal 8:

You need to update at least 3 or 4 yml files

field.field.node.page.field_description.yml

(same change)

field.storage.node.field_description.yml

--- a/config/default/field.storage.node.field_description.yml
+++ b/config/default/field.storage.node.field_description.yml
@@ -4,13 +4,13 @@
 dependencies:
   module:
     - node
+    - text
 id: node.field_description
 field_name: field_description
 entity_type: node
-type: string_long
-settings:
-  case_sensitive: false
-module: core
+type: text_long
+settings: {  }
+module: text
 locked: false
 cardinality: 1
 translatable: true

core.entity_form_display.node.page.default.yml

-type: string_textarea
+type: text_textarea

core.entity_view_display.node.page.default.yml

-type: basic_string
+type: text_default

Maybe the last 2 ones you can deal with those changes on UI(go to each teaser and save). But I did in config folder.


Hide errors from users but show to admin? Under 'Error messages to display' I can hide errors (as is recommended for production sites). However is it possible to hide errors for everyone except a certain role?

Preface: This answer was first posted as an answer to "How do I suppress a warning or error message for site users?".

Disable Messages module

You could use the Disable Messages module for this. Here is a quote from its project page:

  Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal_set_message is an excellent way for modules to send out messages to the end users. However not all drupal site owners are keen to show all the messages sent out by drupal core and all modules to their users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Some of its features are:

  Filter out messages that match a full text string exactly.
  Filter out messages that match a regular expression.
  Permissions to specifically hide all messages of a given type from any role.
  Disable all filtering for specific users.
  Disable all filtering for specific paths.
  Apply filtering only for specific paths.
  Debug system to get messages in the HTML without showing it to the end users.

Available for either Drupal 6, Drupal 7 or Drupal 8.

About using regular expressions

If you're using its 'regular expression' feature, you have to make sure that you use a regular expression that "catches" the error message you want to intercept, as explained also in the Community documentation.

Below "Tip: Keep it simple." on that page, there is a great sample, which looks like so:

  Be aware that something that appears very straightforward like:

Notice: Undefined index: field_txt_student_id in ctools_entity_form_field_content_type_render() (line 96 of [...]entity_form_field.inc).

  Has a lot more unseen characters in it than one might expect:

Notice: Undefined index: field_txt_student_id in ctools_entity_form_field_content_type_render() (line 96 of [...]entity_form_field.inc).

  So just wrap the meat of the grep with a simple "any character" regex: ".+" as in:

.+Notice.+Undefined index:.+ctools_entity_form_field_content_type_render.+entity_form_field.inc.+

So the "clue" to come up with a correct message, is to shrink the error message you want to catch, and putting ".+" characters where appropriate.

Talking about shrinking, note that the field_txt_student_id has been omitted in the regular expression also (to make it NOT depend on the field name).

Example

As another example, assume you want to catch this error message:

  PDOException: in dblog_watchdog() (line 160 of /home/dbuser/public_html/yoursitesname.com/modules/dblog/dblog.module).

In this case a possible regular expression should look something like so:

.+PDOException.+in dblog_watchdog().+(line 160 of.+/modules/dblog/dblog.module).+

Note how I intentionally did not include part of the path before /modules/dblog/dblog.module (so that it can be reused in another site where the very same error occurs ...).

Also note that you have to give it some thought to yes or no include the 160 part of it: if the module ever changes a bit so that in the error message it (eg) becomes line 161, your error will not be intercepted anymore. To avoid that, omit the 160 part of it, if that's what you prefer (personally I would rather first see the error coming back then, and then re-adapt my regular expression).

If your regular expression doesn't work at first (= the message still appears), then it might be because there is some typo in the regular expression. To pinpoint such typo, first try with a less restrictive regular expression, even if it was only to try with something like so (to catch ALL messages containing PDOException and dblog_watchdog):

.+PDOException.+dblog_watchdog.+

Or even like so (to catch ALL messages containing PDOException):

.+PDOException.+

These last 2 expressions would probably suppress way too much messages, so you'd want to narrow it down to that single one you're after.

Unstable alternative

There is also the Better Messages module as an alternative. However, for D7 (which is what this question is about), it only has an Alfa version.


How to make CKeditor format code indenting elements and adding line breaks? Using CKEditor in Drupal 7, I could configure CKEditor to format the code adding line breaks and indenting the HTML code automatically.

For example, pasting this in the source code:

Test

CKEditor could be configured to turn it into:

        Test

To achieve that, I just had to select the right configuration for CKEditor (Indent the element contents, Break line before the opening tag,  Break line after the closing tag), and include the Javascript configuration:

config.allowedContent = true;

But in Drupal 8, I can't see those options and CKEditor removes all the whitespace from the source code.

How can I make CKEditor work like with that configuration in Drupal 8?

Finally I found a solution, thanks to the post CKEditor with well-formatted html source code.

I just added to a custom module the following code:

function mymodule_editor_js_settings_alter(array &$settings) {
  foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
    if ($settings['editor']['formats'][$text_format_id]['editor'] === 'ckeditor') {
      $settings['editor']['formats'][$text_format_id]['editorSettings']['customConfig'] = base_path() . drupal_get_path('module', 'mymodule') . '/ckeditor_config.js';
    }
  }
}

to include a configuration a file called ckeditor_config.js that contains the code:

CKEDITOR.on('instanceReady', function(ev) {
    // Sets indentation of source code
    ev.editor.dataProcessor.writer.setRules( 'div', {
                indent: true,
                breakBeforeOpen: true,
                breakAfterOpen: true,
                breakBeforeClose: true,
                breakAfterClose: true
            });
});

Doing this, CKEditor will keep the indentations in the source code, and a well formatted code easy to read.


The "more" link does not direct to the page I am very new at using Drupal some of the answers I see here seem to be the solution but I don't understand the terminology, so if some could explain in simple terms step by step I would be grateful. The problem is that I create a press release which appears on the front page as expected together with a "more" link, however, this does not direct one to the actual article but back to the page I am already on. Please if someone could help me and guide me through the procedure to fix this I would be very happy. Ian

I guess what's been bothering you is the "preview" of you nodes.

First, by default, your new "content" ( i guess you are using articles) are promoted to the front page, but that's not where you can find all of them, especially the older ones. It's works like a "latest news" page.

Second, those articles are shown as a "preview", only the first few lines of its content can be read. The "more" link send to the full content of your article.

This link appears even if the article is short enough to be completely read in preview mode, because, only inside the page with the full content you can, for example, add comments etc... etc...

Maybe you didn't notice this because right now the articles you are writing for testing purpose are just too short


CSS and JS 404 On Admin Site Only - New Install This is a new server build...

me@server:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

Apache...

me@server:~$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2019-09-16T12:58:48

I downloaded the Drupal 8.7.8 tar.gz and installed using the Standard installation profile into an Apache VirtualHost.  The visitor portion of the site displays and functions as expected, however the admin portion has issues.  The main page, /admin, displays styled.  However, clicking on the various links, Content, Structure, Appearance, etc, result in a page with no style.  Inspect's Network tab shows...

http://my.server/admin/sites/default/files/css/css_<snip-long-random-string>.css?0
...
http://my.server/admin/core/assets/vendor/modernizr/modernizr.min.js?v=3.3.1
http://my.server/admin/sites/default/files/js/js_<snip-long-random-string>.js
...

Still in Inspect on the Network tab, the CSS files show a Status of "(cancelled)" and the JS files are all 404.

Maybe I have something wrong with URL rewriting.  During installation in the "Requirements review" I received the warning about clean URLs - the server is capable but not enabled.  Well, mod_rewrite is enabled and I have the following in my VirtualHost config...

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

With setting RewriteEngine off the visitor site only partially works.  For example, the contact form is 404 while search works but has no CSS.

All other prerequisites passed.

I removed the whole Drupal filesystem and dropped the database.  Another new installation yields the same results.  Further suggesting that this is an Apache config issue.

Your time and help in resolving this is appreciated, thank you.

== Edit ==
The more I investigate the more I feel this is rewrite related.  I moved all of the Rewrite statements into the top <Directory> and the site, visitor and admin, is 100% broken and I now receive the following in Apache's error log...

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
AH00121: r->uri = /index.php
AH00122: redirected from r->uri = /index.php

The last entry is repeated a number of times.  I have LogLevel debug.

I understand the result but I'm not sure what the Rewrite statements should be and where they belong.  My [current] vhost...

<VirtualHost *:80>
    ServerName [redacted]
    DocumentRoot /var/www/html/test
    <Directory /var/www/html/test>
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteOptions inherit
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
            RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    </Directory>
</VirtualHost>

Don't forget AllowOverride All if your Apache is defaulted to AllowOverride None.  The missing directive was prohibiting rewriting from working [properly?] since I had, lastly, moved the rules to .htaccess (where they are in a default installation).  Added it to the "main" <Directory> in my <VirtualHost> and all is well.


Promoted to frontpage teasers in a block General:

I am new with Drupal; so, I was trying to add new regions to Zen (sub)template, but got very confused why contents of my new-created region "content 2" appears on page above the original so called "promoted to front page teasers", which I considered to be a "content"...

Now, it seems "promoted teasers" are not in a block - and that's why they are not in a "content region"?

If so, How to put "promoted teasers" in a block?

Also confusing - what do "main page content" block? - It seems I cannot disable it and if I put "main page content" in a "content" region - my new "content 2" region appears above the "promoted teasers" ; if I put this "main page content" block in "content 2" - both content of "content 2" and "promoted teasers" appear next each other in the same row (?!)....

May be it depends somehow on CSS also?

I don't know, I just somehow assumed that "promoted teasers" are "content" region's content, but it's not - so, what should I do with it now?

Ingredients used:

Drupal 7.30

Zen 7.x.5.x

Display Suite

Views

few others...

      <?php print render($page['highlighted']); ?>
      <?php print $breadcrumb; ?>

      <?php print render($title_prefix); ?>
      <?php if ($title): ?>

<?php print $title; ?>

      <?php endif; ?>
      <?php print render($title_suffix); ?>
      <?php print $messages; ?>
      <?php print render($tabs); ?>
      <?php print render($page['help']); ?>
      <?php if ($action_links): ?>

<?php print render($action_links); ?>

      <?php endif; ?>
      <?php print render($page['content']); ?>
      <?php print $feed_icons; ?>

    <?php
    // content - 2 region , my own added
      print render($page['content2']); ?>
     <?php print render($page['content3']); ?>
     <?php print render($page['content4']); ?>
     <?php print render($page['content5']); ?>

Use Views:

Create view of content
Create "Block" display
Use filters to only show ones with "promoted to frontpage" selected
In Format section set  Show: Content | Teaser
Put your block on the frontpage

That's all.


When using Entity Translation and the Title module, how can I get the translated term from the term ID programmatically? I have a term ID and I want to programmatically get the translated term name (via Entity Translation and the Title module) for the logged-in user's language.  How can I do this?

This similar question asks about how to get the translated name programmatically when using i18n taxonomy translation (the other major approach besides Entity Translation).

The proper way to do this without circumventing the core API would be:

$tid = 322; // put here your term id
$term = taxonomy_term_load($tid);
$langcode = $GLOBALS['user']->language;
$translated_term = $term->name_field[$langcode][0]['value'];


View should show related articles from shared reference field - relation from a relation I have two content types: Article and Magazine. in Article there's an entity reference field to Magazine, field_related_magazines.

On my website, when an article is shown, I would like to show a list of related articles that share the same magazine.

When I make a new article, I can choose the magazine edition in which the article appeared.
Then, on the bottom of the node page, all other articles should be listed.

The thing I tried:

Make a views block 'Magazine related items' that lists Article titles and place the block on the Article pages.

Set the context for the block to work: Advanced>Contextual Filters>Content ID>Provide default value>Content ID from URL

Set the relation: relationships>Content using field_related_magazines (relate each Content with a field_related_magazines set to the content item.)

However, this only shows the current articles' title, not the titles of all other articles that share the same magazine.
How would I get all the others?

In order to fetch resources under specific Megazine, you need to have the Magazine ID on your contextual filter instead of the Article ID. Here is my suggestion:

Play with your URL pattern to add the magazine ID to it (You can do this using Pathauto and Token Module). Once you install those two modules define a URL Pattern for your articles (/[node: field_related_magazines:entity]/[node:title])

Now you each article page will have a URL with Magazine ID to it so, you can change your contextual filter to get Magazin ID from the URL using "Raw Value From URL". This will give you the result you are looking for.


How do I create a progress bar? I need to implement a progress bar using Drupal 7. This is the code I am actually using.

$form[$name][$name.'_enc'] = array(
  '#type' => 'submit',
  '#value' => t($name.' Enable'),
  // '#submit' => array('submit_'.$name.'_enc'),
  '#ajax' => array(
    'callback' => 'submit_'.$name.'_enc',
    'wrapper' => 'ajax-response-goes-here',
    'method' => 'replace',
    'effect' => 'fade',
    'progress' => array (
      'type' => 'bar',
      'message' => 'convert..',
      'url' => 'misc/progress.js',
      'interval' => '1500'
)

What you set as ['#ajax']['progress']['url'] is wrong: It's not the URL for a JavaScript file, but it's the callback path to use to determine how full the progress bar is. The menu callback should return a value that indicates if the operation has been completed, or it is completed at 10%, 20%, 50%, etc. Looking at the code contained in the progress.js file, I notice the value is expected to be between 0 and 100.

As side note, the value passed in ['#ajax']['progress']['message'] should be passed to t().


How can I hook into an entityform submission? I've got entity forms installed, and I'd like to use some db_queries when a particular entity form is submitted, as to make use of the information filled out on that entity form.

Is this possible, and which hook should I use?

If I understand your question right, you should use the following hook to capture a submission:

hook_entityform_insert($entityform)

As described in the comments at the top of entityform.api.php:

* Entityform and Entityform type are standard entities using the Entity API module.
* The standard Entity hooks are availabe for them.
* Including
*  ...
*  hook_entityform_insert

Hope this helps

Addition:

here is the sample code I used:

function mymodule_entityform_insert($entityform){
  dsm($entityform);
}

and it did get triggered as soon as I submitted an EntityForm.


How to change position & amount of fields in content type dynamically (means by editors) I have a content-type, that can be structured like this:

content-type A

title
summary

part one title
image
text

part two title
image
image
image
text
image

part three title
text
image
text

I have no control about the position and the amount of elements that can occur. I just have the types, like heading, text, image. Actually i have only fields or rather field-groups.

How can i give the editors the possibilty to move these fields or field groups inside the content type so they can determine the position? Is there something like nodequeue for fields?

Or should i alternatively cut the content-type to smaller pieces and organize it with nodequeue? I haven't worked with nodequeue before, is it possible to give a queue a menu-entry for example?

edit: Just before i asked my question i was watching a tutorial of Display Suite and if i understood correctly i can change the layout of a content-type globally. I'm looking for a solution that gives more control over each "article" created with a content-type. Maybe i was unprecise in my question...?

If I get your question right you want both the number of parts, the combination within the parts and order within the parts to be different. This may be a little difficult to implement but definitely doable.

I am assuming that you are going to have only title, text and image type in each of these parts.

Using fieldset module create three field collections name weighted title(containing textfield with cardinality as one and weight[integer value with cardinality as one]), weighted image(image field and weight field) and weighted text(containing a text field and weight field)

Now create a field set named type, add weighted title, weighted image and weighted text as the fields in this fieldset. Make sure that you keep the cardinality of these fields as infinity. To make sure that it is not confusing, we will need to remove the drag and drop option withing the type fieldset.

The UI needs to be worked on to make it more intuitive. Without these enhancements to implement

part two title

image
image
image
text
image

We will have to do it as

Solution :
title 1
image 2
image 3
image 4
image 6
text  4

and for

part three title

text
image
text

Solution :
title 1
text 2
text 4
image 3

Hope you are not lost :P


how to get banner image based on the role? I want to have a banner in home page which should change according to the logged in user role.How can i achieve this?
I'm trying edit 'page--front.html.twig'. But i'm not able to fetch logged in users role.How to check user roles inside this twig file?

Considering you have created multiple Blocks for individual role  from Drupal admin UI.

You can restrict each block role wise.


How to grant access on some functionnalities in system dashboard to a given role How can I grant access on system dashboard to a given role.
Let's assume the role is "Webmaster". So when a user with this role logged in, he will land to the admin page as if he belongs to the "admin" role, but with fewer options available.
For example he will not be able to see the "configuration" menu, and so fourth...

Because what I actually have is, when this kind of user logged in, he lands on a user page like other authenticated user (I mean a regular front page).

Thanks for your help

By default, when a user logs in on Drupal, they are redirected to /user (the user page). If you want to change that behavior (so they are redirected to a custom dashboard page that you create (ie: /admin/dashboard) you might be able to use Rules (assuming you are on D7 - Rules is not ready for D8 yet as far as I know). You would create a Rule that triggers when a user logs in, add a condition to check there role, and an action to redirect them to another page.

You may also want to read this, because there may be more conditions you want to include, so that they are NOT redirected when they are resetting their password, for example: https://www.drupal.org/node/480584

As for hiding Configuration menu and other things, that is accomplished by assigning (or not assigning) permissions to the user roles. So your admin role should include access to Configuration, but your other roles should not.


Trigger when a user clicks on a link I have a menu listing different links and on some of the links, I want to trigger a notification to the User. I'm working on drupal 7. Also please let me know what modules I would need in the process.

Thanks!

Have you looked into the Rules module? It's great for making conditional actions and can do stuff like sending out mails.


Prepare name and address for use with drupal_mail() I'm having problems with certain characters when using the drupal_mail() function.

Here is the apache error.log entry for the issue:

  Ignoring invalid 'To:' recipient address '=?UTF-8?B?IsWgxZLFvcWhxZPFvsW4wqXCtcOAw4HDgsODw4TDhcOGw4fDiMOJw4rDi8OMw40=?=  =?UTF-8?B?w47Dj8OQw5HDksOTw5TDlcOWw5jDmcOaw5vDnMOdw5/DoMOhw6LDo8Okw6XDpg==?=  =?UTF-8?B?w6fDqMOpw6rDq8Osw63DrsOvw7DDscOyw7PDtMO1w7bDuMO5w7rDu8O8w73DvyI=?=  =?UTF-8?B?IDxjaXRyaWNndXlAZ21haWwuY29tPg==?='
  Transaction aborted: no recipients specified

For sake of example, what would be the simplest way to successfully send an email (In the RFC2822 format of "User <user@example.com>") to:

ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÍÎÏÐÑÒÓÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñóôõöøùúûýÿ <example@example.com>

Currently drupal_mail() fails with:

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

Preferably, I would like to be able to keep these special characters intact.

Otherwise, could I use a project like Transliteration or Pathauto to convert or prepare the string? If so, which project and function should I use to prepare the "To" name?

Drupal Log Message:

All credit to @deceze

Original Solution

In short:

mb_internal_encoding('UTF-8');

$name  = '山本';
$email = 'yamamoto@example.com';
$addr  = mb_encode_mimeheader($name, 'UTF-8', 'Q') . " <$email>";


Views: nodes grouped by taxonomy term I would like to show nodes grouped (aggregated?) by taxonomy term like this:

term 1

node1
node43
node34

term 2

node23

etc. but I am not seeing such grouping when I enable aggregation. I can get sg similar with table style and group by column but this only works for the current page, not if I have a paged view.

Any tips? What would be the steps to achieve this with aggregation?

Similar question but for D6

https://stackoverflow.com/questions/2712856/how-do-i-make-a-view-that-groups-nodes-by-taxonomy-term
https://drupal.stackexchange.com/questions/18320/print-nodes-grouped-by-taxonomy-term-name

For future reference, I think this recipe is pretty awsome: http://www.drupalgardens.com/documentation/taxonomy/views


Book navigation block? Where is the book navigation block in Drupal 8?

The structure guide for Drupal 7 says you just need to turn the navigation menu on by enabling the block.

  ...One navigational aid you can use is the book navigation block,
  which you can enable on the blocks page administer >> site building >>
  blocks (Drupal 5 and 6) or Dashboard >> Structure >> Blocks (Drupal
  7). Enabling this block will turn on a menu that shows where the user
  is in your book; the menu is only visible when viewing the book.

But there doesn't appear to be a "book navigation block" in Drupal 8 as far as I can see.

Where is this block hiding in Drupal 8?

You need to click on one of the "Place Block" buttons displayed beside all the region names, a popup with all the unused blocks appears and you select it from the list to add it.


How to remove Powered by Drupal? I just installed Drupal 7.2 on my localhost using xampp, made some pages, and installed a theme, I'm also modifying the CSS of the theme to my own convenience.

My front page has (at the end of the content, not the footer) a "Powered by Drupal" written over there. In WordPress I would just edit the content PHP file, and delete that; with Drupal, I can't find where the line is located.

I thought the index.php would give me some ideas, but I think Drupal works differently.

How exactly do I find my front page in the directories? I have a c:\xampp\htdocs\drupal7 main directory.

Drupal constructs the pages you see using blocks and nodes through a template file. To find that text, look in menu option "website information", next if not found look in the block list for a block placed in copyright or footer area.

Drupal will depend on block/regions; learn that too. Finally, when that doesn't work, in /sites/all/themes/ you'll find the PHP and HTML files delivering the themed page.


CKEDITOR is not defined? I've installed Wysiwyg with CKEditor and set up a profile for the editor. However, the CKEditor toolbar isn't showing up. When I add new content Firebug shows the following script error:

CKEDITOR is not defined

It highlights line 144 of /sites/all/modules/wysiwyg/wysiwyg.js:

CKEDITOR.config.customConfig = '';

I'm really not sure how to solve this problem. Do I need to manually define CKEDITOR.config.customConfig? If so, what should its value be?

I should add that this is a fresh Drupal install (version 7.27) and that I'm using Wysiwyg 7.x-2.2-dev with CKEditor 4.4.0 (standard version). The reason for using the development version of Wysiwyg is that the stable version is unable to detect CKEditor.

Yeah, I can confirm Molots statement.

Try to use CKEditor 3.5.3 with the newest Wysiwyg.
Even with patches I could not solve the problems between CKE 4 and wysiwyg.

regards,
SuperEngineer 64

EDIT: Also possible is to install the Develpoment-Version of Wysiwyg. I use it mit CKE4 now.


Validate form: at least one of the fields is required Users need to fill link fields wrapped in a field group to their various social profiles like fb, twitter, pinterest. I  need them to give any one of the fields as required since I use it to verify their profile.

I've tried conditional fields and field validation. Field validation require one of various fields gives me like seven "one of the fields is required" messages for all seven fields.

I tried different configurations with conditional fields without results.

Is there a workaround with any other modules?

Where are these fields attached to? User registration page or content type?

Anywhere it might be, there must be a form, and what you need to do is add a form level validation function, not a field level validation. Field level validation works well, when logic is associated with that particular field but for your case you need to add form level validation handler:

Here is an example:

/**
 *  Implementation of hook_form_alter().
 */
function yourmodulename_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_register': // or whatever is the form id in which you want to apply validation
      // this line adds a new validation function
      $form['#validate'][] = 'custom_data_validate'; //or whatever validation function name
      break;
    }
}

/**
 *  Custom validation function.
 */
function custom_data_validate(&$form, &$form_state) {
  $values = $form_state['values'];  //all submitted values will be in this array, keyed by the name, grab any value you want.

  if (empty($values['facebook']) && empty($values['twitter'])) {
    form_set_error('facebook', t("you need to fill up either of the two fields"));
  }
}

I did not take care of the logic and the code provided is just an example but the basic workflow is:

Alter the form and add a custom validation function.
All the submitted values will be available in $form_state in the validation function.
Check the logic and trigger a form_set_error() to set the error.


Could a content type be corrupt? I just update a site from Drupal 7.14 to Drupal 7.15 and made some other modules updates.

One of the content I have created in the site is Inmuebles

The site have around 200 nodes of the Inmueble type. All of them are shown fine. But if I tried to edit them I get a blank page (nothing at all).

I tried to Edit the content type Inmueble itself and I get a blank page.

I tried to Manage the Fields and I get a blank page.

I have no problems with other content types, just with this one.

I guess this content type has a mis-configuration but I see no way to fix it if I can't access to modify it.

If I delete the content type because I will delete the nodes as well, then I can't do that.

What can I do? I have Drush installed, just in case it helps to fix this.

UPDATE

Found the problem (but not the source of the problem)
It was a problem of memory size. I had to set the memory size to 512 to get the content type loaded. But this is not normal anyway. The page takes 1 minute to load... and why does this content type need this much memory to work fine. How can I fix this?

I enabled  Display query log , Display memory usage and Display memory usage
Now if I edit a node I get this summary report:

  Executed 731 queries in 555.96 ms. Queries exceeding 5 ms are
  highlighted. Page execution time was 3058.65 ms. Memory used at:
  devel_boot()=2.08 MB, devel_shutdown()=135.13 MB, PHP peak=137.25 MB.

You can export all the nodes of content type "Inmuebles" with the drush command

drush -u 1 ne-export --type=inmuebles

Then maybe try deleting the content type and creating it again.

Although it doesnt make sense for a content type to just get corrupt, maybe if you check your error reports or apache log you will get a better look.


How do I use URL aliases in menus? I am kicking the tires on Drupal 7 by spinning up a test site.

I chose the Danland theme and created various pages with URL Aliases for each, but when I create the Menu link for each, I can only enter the node in the "Path" field for the menu link and not the alias. So I can only enter "node/20" and not "about-us" (the alias for the node) in the menu.

I'd like the menu items to resolve to the aliases and not the nodes.
How do I do that?

Like Berdir mentioned in the comments and Greg mentioned in his answer, the following methods of adding path aliases should Just Work™:

Adding it on the node submission form during node creation/editing
Using Pathauto to automatically create aliases for nodes.
Adding aliases manually by going to Configuration → Search and metadata → URL aliases

That it's not doing that is weird. Try clearing your cache by going to Configuration → Development → Performance. This should rebuild Drupal's menus and get the path aliases to show correctly.