Contact email flood limit is per whole system(application) or user/ip based? I have a question with contact emails flood limit which is present in contact.settings.yml, the limit is going to for whole system(application-wide) or is it going to limit the number of emails per individual user or IP?

As you can see its number of emails a user  can send in an hour

https://www.drupal.org/docs/8/core/modules/contact/overview#controlling-repeat-submission-blocking-flood-control

You can specify the text to display on your site-wide contact page and you can optionally limit how many times a user can submit a contact form in an hour.

btw, its defaults that you can override per any contact form . for example :
contact.settings.yml

default_form: feedback
flood:
  limit: 5
  interval: 3600
user_default_enabled: true


What to do about an 'illegal Choice' error in views? I have a view with an exposed filter and it isnt working correctly.  I am trying to change the options on the exposed filter but all that happens is I get is 'An illegal choice has been detected. Please contact the site administrator. '  I cant find anything logging anywhere.  This error is incredibly vague and tells me nothing about which choice is illegal or what legal options may be.

Is there somewhere this may be logged that I am not looking?

'An illegal choice has been detected. Please contact the site
  administrator. '

This type of issue generally arises when, for example, you have 2-3 select list, select list 'second' is dependent on 'first' select list. Now if you get empty result (say) in your first select list, second select list will not get populated correctly and throw this type of exceptions.

This is just an example so that you might get an idea, the sequence of selecting values is not right.

Try the whole procedure again, and this message will get disappeared.


Including a view in a content type I have the panels module installed. So I have two types of pages:

Under the Create content/Page, the basic content type
Under Site Building/Pages/Add Custom Page, the page with panels

So, I've used the Panel pages all over the place and everything is easy; however, for a particular project, I have some content-types that were based off the basic Page (example 1 above).

I need to figure out how to add a view to that kind of page. There is a lot of HTML with jQuery setup to allow for a custom tab system on one page: Click on a tab and via show/hide the appropriate content shows up and adds a hash tag to the url for deep linking.

I'm guessing I will select PHP code for the input format, but I haven't found the right snippet to include a particular View within all the HTML code that is already there.

I tried to just use <?php print $content; ?> within the div for the last tab of content to see if I could get something to render but it didn't show anything so perhaps this isn't the right way anyway?

Some notes

My view has four displays and I need to call the one "ISO 14001 docs" but, the view has an argument of "(Document) Content: Link" so that is probably why I have not been successful.

I've tried the following code, but I'm not getting anything and I'm not sure how to add that type of argument in this kind of call.

$viewName = 'sc_file_view';
print views_embed_view($viewName);

You can use Views Reference module that will give you a cck to choose from selected views. This will use with each type of content.

For a same view in all content of content type you will need to create a template file node--type.tpl.php and paste your code to include the view.


Dynamic webform recipient I am developing a site which has many advertisers. The idea is to have a specific advertiser emailed when a user shows interest in their product.

To do that, I need to create one webform which will change the recievers address dynamically depending on the advertiser who posted the product of interest.

It sounds like a custom module solution but I need the opinion of those who know better than I do.

Thanks

As it turns out, webform 3 has the ability to create an email component which will serve as the recipient.
All I then did was to copy the desired email address into the email field using JQuery. I did so dynamically on each user page and it works just fine.


CCK fields don't appear on the "node add" form for authorized user I would like to allow logged-in users to create nodes, and I gave them the permission to create "some_content," but on "add node form" users have only one field, which is for custom node title, without any other CCK fields that this content type have. Could anybody tell me how to add those fields to this form?

Most likely you have a module enabled that adds access control for each field. Check your permissions setup.


Is there a way to search for instances of hook_views_query_alter() in my database? I am running a D7 site that someone else built and I'm having trouble seeing how an SQL command in a particular view has been altered. In particular, the attributes in the SELECT statement appear to have been altered.

Is there a way to search my database to see if the person building the site added an errant hook_views_query_alter command that is the reason the SQL filter looks different than one would expect just looking at the fields in the View?

Or is there another, better way to debug this issue? Thanks for any help!

Views field output can also be rewritten under the view's fields setting in the views interface using "rewrite the output of this field" using tokens from previous rows or arbitrary HTML. That's the likeliest place.

If not there, the next candidate for views output modification is in the theme template files. People will stick any kind of logic in views theme template files. To see if custom template files are in use, see "Theme: Information" in the views and the template file in use will be in bold.

Generally, hook_views_query_alter is not the normal way of modifying a view. But a hook_views_query_alter would be added in the code rather than the database. Drupal does cache a list of implemented hook functions in a the theme registry table, but that's not very readable nor informative. Not where you should be looking. Your best bet is to search your code for "_views_query_alter" and see what you turn up. There will be a lot of results, but likely you'll recognize any custom modules.

I might also turn on Show SQL Queries in under Views->Settings to see the output of the views query as views reports it as it's being run in the Views preview interface below the view builder interface. Then you can see the query being run to see if it matches your expectations.

There is also a setting in views under Advanced -> Query to turn off SQL rewriting for a view. This will disable access checks as well as some query rewriting (but not all) so use sparing.


automatic class to all boolean fields I have a Boolean field on a content type. Possible values are completed and not completed. The default rendering is not satisfactory though since it doesn't include any CSS class to represent the boolean state (true, false) so I cannot act on this using CSS or JavaScript.

Completion status:&nbsp;

completed

What's the best way to add such a class on .field or .field-item?

What I've tried so far:

hook_field_display_alter but this doesn't provide me with data nor field type
hook_node_view but I cannot iterate fields by type. I'd need to pinpoint the specific field instance I need to modify but I don't know that in advance.
by providing a custom node template, but this solution is not generic for all occurrences of a boolean field

You can implement hook_preprocess_field() and add the class there.

Get field type :

$element = $variables['element'];
$type = $element['#field_type'];

Add something to field class :

$variables['classes_array'][] = 'class-name';


Is it possible to turn off the auto-pathing for the Pathauto module? I use the Pathauto module for several uses, such creating URL patterns.

I do want to turn off only the main feature of the module which is --- Auto path creation for nodes... Why? Because some of my H1's aren't in English, but the alias should be English and be setted manually. An efficient solution will be:

Finding a way to disable this specific functionality of the module so I could still use all it's other functionalities, and not lose it completely.
NOT BE ABLE to save the node only until I manually wrote an alias (if I saved it with a no-English alias mistakenly this could be problematic for SEO if I change it after the webpage has already been indexed).

You might came across any solution for this?

I don't know if this is possible without implement the hook_form_alter() function but you can use a different approach to solve the issue.

You can use a custom field instead that the title of the node.
Set the field as "Required" and in /admin/config/search/path/patternsset the pattern of the node with the token of the field instead that the title (ie: [node:field-seotitle] ).

In other words:

Add a field in your content type, for example: seotitle;
Set the field as Required;
Go in /admin/config/search/path/patterns;
Set the pattern of the your content type where you have add the field with the token of the seotitle field (ie: your-content-type/[node:field_seotitle]);

In this way you can choose a title for the path alias and save the node only until you have a seo-title;

I hope I explained myself.


Storing the value of a form submission in a hidden field or the database So I have created a form for user's to store some documentation about a node they have created but I do not want this documentation to be shown on the node's main page.  I would like the main page to have a link to either view or edit the form.

Now as far as I can tell there is no way to create a field that doesn't show up directly on the node create or viewing pages (this seems like it would be a misuse of a field anyway).  Is there anyway that I could store what the user enters in this documentation form as part of the content without it being displayed on the node page or would I have to create a database table that associates a nid with the documentation string?  Also, my form allows for use of filtered html in the form, will this be preserved if I store the filtered html as a string in the database?

if you want a field not to show up on the node page you can either

hide it in display options: Structure -> Manage display (in front of the corresponding content type) -> Format -> Hidden
Hide it in the template file by calling

hide($content['YOUR FIELD NAME']);

The first option makes more sense in my opinion.


How can I show a single block only if the user is on iOS? I have a Picture content type that allows users to upload picture files, something that iOS does not support.  Since Apple in 2012 can't support something my first computer running Netscape Navigator was able to do in the early 1990s, I'd like to give a message to iOS users that they will have to e-mail me the photos instead.

I installed the Browscap module but it only detects the user agent; it doesn't do anything by itself.  On Drupal 6 I used Mobile Tools, but it has yet to see a stable release for D7.

I only want to show a single block on a single content type to iOS users, so I'm looking for the simplest possible solution.

My dull ax dealing with this same issue boils down to a little module helper function along the lines of:

function _MODULE_is_iOS() {
  if (strpos($_SERVER['HTTP_USER_AGENT'],'iPad')  !== FALSE ||
      strpos($_SERVER['HTTP_USER_AGENT'],'iPhone')!== FALSE ||
      strpos($_SERVER['HTTP_USER_AGENT'],'iPod')  !== FALSE) {
    return TRUE;
  } else {
    return FALSE;
  }
}

and then using that within my block hooks, eg,

if (_MODULE_is_iOS()) {
   $block['content']= // whatever I need for iOS
}

or from within the Block Admin PHP visibility area if in a pinch.


Using entity form display modes I have created a custom form display mode my_mode for nodes and wish to display node form using this mode instead of default one at a custom page. How can I do it?

$this->entityFormBuilder()->getForm() accepts an operation as a parameter, but not form mode.

Form modes and form operations are a bit strange. You also need to define a form operation through hook_entity_type_alter() to be able to use a custom form mode.

Which makes the UI to create form modes pretty useless, but ssshh, don't tell anyone :)

For an example, see views_ui_entity_type_build(): $entity_type->setFormClass($operation, $class_name)


Replacing tokens in Newsletter I'm trying to create a custom template using the Drupal Newsletter module.

I need to populate the newsletter with existing content. For this, I think I need to replace a token like [node:nid] in the newsletter body (which is created with CKEditor). However, I have been unsuccessful.

When I use the token filter module, I'm only able to replace global tokens like date or [site:url] and not tokens involving a node. Can someone please help me out?

Tokens are contextual based on where they are used, so it's not possible to reference arbitrary content. If you can add fields to the newsletter, the ideal way to resolve this would be to add a node reference field, then create your tokens by doing something like [newsletter:field_node[0]:entity].


How to send hidden field value to db on webform submit I am using Drupal 7 webform api, have a created a field in my _form_alter hook in a custom module, but while on page load the hidden field contains the correct value, when I submit the form it does not save to the mysql table, and gives me an empty cell

$form['State'] = array(
  '#type' => 'hidden',
  '#value' => 'Unread',
  '#attributes' => array('id' => array('stateform')),
);

How can I make it save to the mysql table on submit?

UPDATE:

$form['State'] = array(
'#type' => 'hidden',
'#title' => t('Hidden'),
'#attributes' => array('id' => array('state')),
);
drupal_add_js(drupal_get_path('module','mymodule') . '/js/custom.js');

You also will need to write a hook_form_submit for your form. In the _form_submit() you will take the hidden value and store it where you like.

That is the simple answer for your question. If you provide more details there could be other ways of handling the data. What is your form action?


Pages broken after update I have recently attempted to update from Drupal 8.2 to 8.3.  After updating, all pages that use Display Suite do not render correctly. The markup generated contains a bunch of "<>" instead of the proper markup, and when I go do Display Suite configuration, all custom of fields of the node types that previously were used are do not show up in the list of fields to be placed in the layout elements.  Anyone have idea as to how to troubleshoot something like this?

For Drupal 8.3.x you need to update Display Suite as well to 8.3.x (as is stated on the module page: https://www.drupal.org/project/ds).

  IMPORTANT NOTICE

  Due to changes in core a new version is created.

  Drupal 8.2 or lower: Use Display Suite 8.2
  Drupal 8.3 or higher: Use Display Suite 8.3

Maybe that's what causing all your problems; possibly, updating the module will solve your issues.


What would be the reason for a registration page to hangs after submit? For some reason whenever i try to submit a new user registration (on a fresh drupal 7 install), the data is correctly sent to the Back end but the page doesn't seem to redirect to the intended location (by default the home page)but instead seems to endlessly submit.

I am pretty sure this come from my testing server as it does it even on a fresh drupal install.
Is there anything that would come to your minds on what could be the cause of this problem ?
We are using ubuntu server with all latest software updates.

Check memory_limit for your Drupal instance.

On settings.php add this line

ini_set('memory_limit', '128M');


error with ownership "The specified file temporary://filelo2Fkx 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."

ANYWAY what I am getting is everything minus theme and all images but strangely my multi site folders in root drupal sites folder are all working fine.

In the end I solved it by putting the root subfolder in sites along with other multi-sites. No amount of changing permissions or ownership or clean install or dropping and recreating database worked until then...which is very odd because it used to before I took the site down.

You can try and change the permission of the folder 'sites/all/files' to give it 777 permission in your drupal installation and see if this works.


How to sort null field values in Drupal? I have a content type with one field of type text.

I add content for 5 nodes.

For 2 nodes among 5, I entered nothing in text-field.

So scenario is 3 nodes have data in that field and 2 of the nodes are empty.

Now I'm sorting on behalf of that particular text-field in my custom module and the result is:

It hides node with empty content.

It means only 3 nodes are visible, empty values are not visible.

Expected result should be, the fields that don't have any value inside should also get sorted and the resulting nodes would be seen either at the top of all sort-able content or below it.

How can I achieve this?

You can achieve it by installing Views Sort Null Field module.

  This module provides an additional sort for FieldAPI fields, which
  sorts by whether the field is empty or not. This allows empty (i.e.
  NULL) values in fields to be sorted last.


how to discover where mini-panels are surfaced in Drupal 7 We have an old, infrequently updated site which has a custom module which we wrote that either needs to be updated or removed.

This module provides two blocks, and if those blocks aren't being used, we can remove the module. Otherwise, we have to update it to use new functionality, which we would like to avoid if it's not necessary.

I looked under the admin/structure/block menu and discovered they are not placed in any regions.

Since I'm a back-end developer, and not really familiar with the theming and templating, I asked one of our front-end devs if the blocks might be used in any other places on the site. She looked through the pages and panelizer stuff, and discovered that the block is being used in a Mini Panel.

So now, the question is, is the mini-panel surfaced to end-users? Nobody presently at the organization is familiar with mini-panels and how they are used. Is there a way, either through the UI or perhaps looking through the tables, to find out of a particular mini-panel is being used?

Assuming your site is using Drupal 7 version.

Mini-panels gives us a way to group together multiple blocks (and other content) into a single block. Which can then be placed on page using Panels or Drupal Blocks (Admin => Structure => Blocks). Check this Question Looking for a good Mini - Panels tutorial for more details.

There are 3 places you can check if Mini Panels are actually used in your site:

Drupal Blocks (Admin => Structure => Blocks) - Block name is usually shown as 'Mini panel: "Mini Panel Name"'
Panel Pages (Admin => Structure => Pages). Check all panel pages by editing them and navigating to Content section of Panel page.
Rendered in Code directly (Since this works similar to block, and can be rendered using the way blocks are rendered programatically). i.e. programatically rendered in theme or module. This might not be in your case, but just to make sure you can check this as well.

This Tutorial shows use of Mini Panels as Drupal Block.

Check out this tutorial on How to use Mini-Panels to create one block that includes all our global blocks - The video is paid, but description gives an overview of what it is.


How to fix Admin Menu that's broken on live site, working on identical dev site I've got an installation of Drupal Commerce Kickstart, and I've been developing it on my LAMP stack on my computer. The admin menu's working perfectly there. I recently migrated the site to the live server (also a LAMP stack), and Admin Menu simply doesn't work. Everything else works.

Specifically, it's being displayed (unstyled) at the bottom of the page on front-end pages (Zen subtheme) and admin pages (Seven subtheme). Sometimes it doesn't even show up at the bottom (it's completely missing).

More info: The version of PHP and MySQL are recent on both sites.

I used Backup and migrate to do the DB migration, with no issues. I've also just updated to the latest core version (7.37), and that made no difference.

Strangely, every other module seems to be working fine, except Admin Menu. And I've never encountered this before on any other Drupal sites I've built.

I have a feeling it's something to do with Commerce Kickstart's interference in the Management menu.

Updates: things I've tried that didn't work:

I've cleared Drupal cache, browser cache, site-specific cookies.
changing all the Admin Menu settings.
uninstalling and re-installing the module.
using a different browser: tried Firefox and Chrome.

It was a file permission problem!

It turns out that, as per Apache's and Drupal's recommendations, I had set the permissions for all folders/directorys in my sites/all/* folder to be 750, and 640 for files. So for those who don't know, that means that 'others' (people who don't 'own' the files or folders) can't access them in any way.

It seems that my web host had incorrectly not assigned Apache to the correct group so that it would be able to run using those safe permissions (I know why, and I'm going to send them an irritated email asap).

I simply used Filezilla to recursively change the permissions to 755 and 644 respectively. Not quite safe, but I can change them back later.


Can't print $base_root in headers view I have a View and inside it I have and Attachment display. In this attachment I set a Header with the value you can see in the image below.
I'm sure I have register_globals = 1;
But nothing is printed...

Well, you need to say that what you want to display is global as well:

<?php
global $base_root;
print $base_root;
?>


How to use voting results to boost relevance for solr search? I am using search api with the solr backend to index thousands of nodes. All of them have votes (vote api). Now I am wondering how to boost the relevance of these notes by their vote. I don't want to sort the result completely by votes (this would be easy), but that the votes boost the node's relevance for a certain percentage. Is that possible? How to do this?

Do you have the voting api results in your apache solr index?
If you do and they are stored under a name ss_votingapi, here is what you need to do:

/*
 * Implements hook_apachesolr_query_alter().
 */
function MYMODULE_apachesolr_query_alter($query) {
  $query->addParam('fl', 'ss_votingapi');
  $query->addParam('bf', "recip(rord(ss_votingapi),1, 1000, 1000)");
}

More here, here and here


How to make a custom block visible if and only if there are no other blocks active in given region The site's header banner is displayed using a custom block containing an image.  Is it possible to create a default block which will return visibility = TRUE only in the case that there are no other blocks which are visible in the header region for the page currently being rendered?  In other words, can a PHP-code visibility test access the list of blocks which will be rendered in the block's region? If not, how can this functionality be implemented?

There is a function that returns the list of the blocks available in a region, but it cannot be invoked from the PHP code used to establish the visibility of a block as it would probably cause a recursive call.

Looking at the code of block_list(), you can write the visibility code for your block. What you need to change is the query that obtains the list of all the blocks to exclude the block for which you are writing the visibility code.

The actual query executed by the function is the following:

$result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));

The function code requires you know the region in which the block is visible; if you move the block in a different region, then you need to change the code used to test the block visibility accordingly.

In Drupal 7, a module can implement hook_block_list_alter() to alter the list of visible blocks.

  Act on blocks prior to rendering.

  This hook allows you to add, remove or modify blocks in the block list. The block list contains the block definitions, not the rendered blocks. The blocks are rendered after the modules have had a chance to manipulate the block list.

  You can also set $block->content here, which will override the content of the block and prevent hook_block_view() from running.


Removing entity queue entries from a view I have a list of 100 projects. I have set 10 projects as featured projects using Entity Queue module.

I have a projects page that shows has two views:

First view: 10 projects from entity queue
Second view: all 100 projects

The issue is the 10 projects are showing up twice on the page, is there a way to remove the entity queue featured projects from the second view?

Any help?

Yes that should be easy enough. In your view with the 100 projects you need to:

1)Add a relationship to the entity queue but DON'T make it required

2)That will make a filter called "Content In Queue" be available for you to add

3) Set that filter to "No"

And that's it any entities that are in the queue won't come out in that view now


How to send an email that always contains all fields of entityform, without manually updating when fields are changed? I have a client with an entityform with over 100 fields (trust me, I begged with them to lessen it). I need to send an email using rules with all of the fields exactly as they appear on the form. I don't want to have to manually add all of these tokens to the email and I also don't want to have to manually update the email with new and/or removed fields every time they change the form. Is there any way of using a token that calls all of the fields on the form and maybe even uses the view mode?

This is already handled in the Entityforms Notifications sub-module the way you are describing.

There is a view mode called "Email".  That view mode controls which fields show up in the email. This is done via a token in Rules.

In Entityform 1.x this token is controlled via the Entityform module itself.  In Entityform 2.x this is controlled via the Entity to Text Module.

I think there is some problem in Entityform 1.x with showing fields with multiple values. But this should work in Entity To Text.  You could also just use Entity To Text with Entityform 1.x.  Just replace Entityform 1.x token with the Entity To Text token in the Rule.

If you are interested this handbook page should probably updated with this information: https://drupal.org/node/1679794


How to make Feeds import only one post at a time when cron run? I have a website which will import many images through Feeds. But Feeds import too much posts which affect the bandwidth.

I want Feeds import only one post at a time when cron run.

The setup:

feeds-6.x-1.0-beta10
Drupal 6.20

There's no way (without hacking the Feeds module) to set this. You can affect how often the Feed updates, so if it's a feed with lots of posts set it to update more often and run cron more often, and that way fewer items will be imported per run because there won't be large amounts of new data to import each time.


Changing position of the header in a view I have the "Result summary" in the Header for my view however, it is being displayed at the top of the content. I would like it to be displayed in between the search form and the search results.
I would like a detailed answer, since I am new to Drupal (8) - I have seen an answer about how to change the position of the header (or footer) using a template.

I can't obviously change it using the admin UI.

I am using Drupal 8.

Thanks!

In your custom theme check if there is a templates/views-view.html.twig file

If not you you can get a copy from core/themes/stable/templates/views/views-view.html.twig and modify the position of header section to be below exposed

the content should look similar to the following after your change

...
{{ exposed }}
{% if header %}
  <header>
    {{ header }}
  </header>
{% endif %}
...

This will customize all views in your current installation

If you want to only modify a specific view you can name the file templates/views-view--VIEWNAME.html.twig

Here is more info on the template naming convention


How can multiple sites use a common default theme with site specific customizations? We are using Aegir, we would like to use one core theme for all of our websites which handles common theming. But for specific theming for each site, we would like to handle inside of their custom themes.

Basically this will enable us that we can change common theming in just one theme used by all, instead of making the same changes in every theme of respective site.

One challenge by creating the custom theme in one of websites it will overwrite code from common core theme, but both themes should be present in the same time.
Is there any kind of solution for something like this?

Consider starting from a Base theme, such as Omega, Zen, Bootstrap, etc. Or build your own (custom) theme that you can use as a Base theme (that would be youru "core theme".

And then create Sub-themes (that would be what you named "their custom themes").

Note: the question about "Right way to start with a Bootstrap subtheme?" contains a lot of details to get started with such sub-theme ...


Configuring Aegir to Set Custom File Paths What is the best way to modify the file paths for a site deployed using Aegir?

Aegir installs sites with the file paths pointing in this format:

sites/<sitename>/files

(This path being relative to the site's platform)

What is the best way to change it to a NAS mount, mounted at, say, /var/nasmount ? For e.g., for a site called firstsite.com, the file paths would be:

/var/nasmount/firstsite.com/files
/var/nasmount/firstsite.com/files/tmp

and so on, along with the the corresponding entries in the site's apache conf file.

These lines appear in /var/aegir/.drush/provision/platform/provision_drupal_settings.tpl.php, but I am reluctant to change here as this is from 'core' Aegir (if you will):

  $conf['file_directory_path'] = 'sites/<?php print $this->uri ?>/files';
  $conf['file_directory_temp'] = 'sites/<?php print $this->uri ?>/files/tmp';

Should this be done in:

provision_drupal_settings.tpl.php file above?
Somewhere else?

Ideally, this change would be done once so all sites deployed via Aegir have this in place, and these changes survive the re-verify process of a site and/or platform.

Thanks!

The answer is to mv siltes/firstsite.com/files to /var/nasmount, then create a symbolic link to it.
(from inside your sites/firstsites.com directory,  mkdir /var/nasmount/firstsite.com, mv ./files /var/nasmount/firstsite.com, ln -s /var/nasmount/firstsite.com/files files).

I would put this in a script so this becomes a drush command, then make it run at the end of the aegir create a site process.

I'm not an expert of where to put this script and/or how to create it.


How to use WYSIWYG editor with structured content in Drupal 7? I am wandering what would be the best strategy to combine a WYSIWYG editor and structured content. I want the user to be able to add the following in the body field with a WYSIWYG editor:

Images
Links to other nodes
Links to, for example, YouTube

I also want to be able to have these added images, links etc. as structured content (to put them out in a view, for example.)

Is there a solution for this? I think the best way would be to use entity reference module for that.

For images use Insert module. For other fields, like YouTube links and entity References, you can create your own module based on Insert's code, or expand it's capabilities and put a patch in Insert's issue queue.


Altering the Title of node using Preprocess I am trying to alter the page title of history content type using this function

function mytheme_preprocess_page(&$variables) {
   if(isset($variables['node']) && $variables['node']->type == "your_content_type") {
   drupal_set_title("my_title");
 }
}

But you know what, I dont get anything in node array.

You could use hook_node_view, which also gives you more flexibility, (e.g. control what view mode / language you affect):

function MY_MODULE_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'your-node-type' && $view_mode == 'full') {
    drupal_set_title('your-title');
}

Instead of using a preprocess function, which is better for template changes, (for example, adding variables to it):

  The main role of the preprocessors is to set up variables to be placed
  within the template (.tpl.php) files.

Preprocess and process functions


How to migrate date fields correctly? I want to migrate taxonomy terms from a legacy database to my drupal 7 installation. This is working almost as desired. What I do is basicly define a mapping as described in any migration example, e.g.:

$this->addFieldMapping('name', 'legacy_name');

But when I try to migrate dates I totally fail. This does not work:

$this->addFieldMapping('field_date', 'valid_from');

After some digging I found out I had to enable the Date Migration module, allright. But still, this does not work at all. I discovered some date migration example code and found out I have to reformat the date field in the prepareRow() function. But that feature is very much undocumented. The linked example doesn't work at all.

My current code looks like that:

abstract class MyBasicMigration extends Migration {
  public function __construct() {
    parent::__construct();
  }
}

class MyMigration extends MyBasicMigration {
  public function __construct() {
    parent::__construct();

    #[...]

    $this->destination = new MigrateDestinationTerm('mystuff');
    # this works:
    $this->addFieldMapping('name', 'legacy_name');
    # this does not:
    $this->addFieldMapping('field_date', 'valid_from');
  }

  public function prepareRow($current_row) {
    # checks for malformed date strings in DB and converts to datetime type
    if (($current_row->valid_from = strtotime($current_row->valid_from)) === false) {
      $current_row->valid_from = strtotime('1970-02-01');
    }
    if (($current_row->valid_to = strtotime($current_row->valid_to)) === false) {
      $current_row->valid_to = strtotime('2037-12-31');
    }
    # converts the date to YYYY-mm-dd format
    $format = 'Y-m-d';
    $current_row->valid_from = date($format, $current_row->valid_from);
    $current_row->valid_to = date($format, $current_row->valid_to);
    # creates a date field for the valid_from/to migration mapping
    $current_row->valid_from = array(
      'value' => (string) $current_row->valid_from,
      'value2' => (string) $current_row->valid_to,
      'timezone' => DateMigrateFieldHandler::arguments('Europe/Berlin'),
      'timezone_db' => DateMigrateFieldHandler::arguments('Europe/Berlin'),
      'date_type' => 'datetime',
    );
    $current_row->valid_from = drupal_json_encode($current_row->valid_from);
    # debug result output
    watchdog("PW_TEST", $current_row->valid_from, $variables = NULL, WATCHDOG_DEBUG, $link = NULL);
  }

The date format in database is a string formated like this 2013-12-31.

The prepareRow() function seems to work at all and the watchdog() output looks very good:

{"value":"1970-02-01","value2":"2013-12-31","timezone":{"timezone":"Europe\/Berlin","timezone_db":"UTC","rrule":null,"language":null},"timezone_db":{"timezone":"Europe\/Berlin","timezone_db":"UTC","rrule":null,"language":null},"date_type":"datetime"}

As you can see the returned JSON string includes the correct dates. But at some point now the migration mapping fails at the fields valid_from and valid_to.

If I do a print_r() on a migrated taxonomy term, I get something like that:

[field_date] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [value] =>
                        [value2] =>
                        [timezone] => Europe/Berlin
                        [timezone_db] => Europe/Berlin
                        [date_type] => datetime
                    )
            )
    )

The JSON object got mapped correctly, date_type and timezone just displays properly. But where the hell are my dates gone? Any ideas?

I've been working on this all day now and I can not see any issues with my code. Thanks for any hints!

This is plain awfull and totally undocumented. But I found out:

# creates a date field for the valid_from/to migration mapping
$current_row->valid_from = array(
  'from' => (string) $current_row->valid_from,
  'to' => (string) $current_row->valid_to,
  //'timezone' => DateMigrateFieldHandler::arguments('Europe/Berlin'),
  //'timezone_db' => DateMigrateFieldHandler::arguments('Europe/Berlin'),
  //'date_type' => 'datetime',
);

Two issues with the code above are solved:

The array containing the dates has to contain the fiels from and to. Otherwise it does not understand the date range. I've seen this in the date migration example but never thought the field names are important for the mapping. (I rather used the target names value and value2.)
The array should not contain information about timezone and date types. The DateMigrateFieldHandler::prepare() will do that for you.

The working code above yields:

[field_date] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [value] => 1970-02-01 00:00:00
                        [value2] => 2013-12-31 00:00:00
                        [timezone] => Europe/Berlin
                        [timezone_db] => Europe/Berlin
                        [date_type] => datetime
                    )
            )
    )

Fixed. :)


Panels page - node template - comments won't appear I'm using Drupal 7. I've got a Panel page set up that comprises a content type, followed by up to two page views based on taxonomy terms. The content type is set to allow comments, and when I use it alone (ie. not as part of the node template) the comments works fine. But when I have it as part of the panel page, no comments appear.

Can anyone think of what I'm doing wrong? I've asked this question on the Drupal forums but haven't received an answer.

Thanks

Try checking if you are seeing the teaser view which may remove the comments, otherwise check to see if the panel settings allows the the comments to be shown


How to format an integer field as Date/Time using Views module I created a custom Entity with one of the properties named 'created' and set with the Drupal REQUEST_TIME in seconds. I want to display this property using the Views module as a formatted Date/Time field. The Date/Time format option is not offered on the Views field settings dialogue.

Implement hook_entity_property_info_alter() to describe your custom entity type's properties to the Entity API module, which will then automatically create Views integration based on the types of fields in your database table.

http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.api.php/function/hook_entity_property_info_alter/7

An example of this can be found in the Log module, which has three timestamps (timestamp, created, and changed). It gives each of these a "type" of "date" in the entity property info, which automatically makes them visible to Views as date fields. http://cgit.drupalcode.org/log/tree/log.module#n242


Scoping an admin link to only show for certain node bundles I have 2 node content types / bundles, A and B. each A has a relationship with multiple Bs. When on the edit page, node/%/edit, for A, I want to show a link to the list of related B so that an editor can easily see a prefiltered list of B for A.

I have created a route:

in my_module.routing.yml

my_module.related_B:
  path: '/node/{node}/related_b'
  base_route: entity.node.canonical
  options:
    _admin_route: TRUE

and have configured a view page at the same url node/%/related_b that contextually filters porperly. no issues there.

The link is added to the menu via the my_module.links.task.yml

my_module.related_B:
  route_name: my_module.related_B
  title: 'Related B'
  base_route: entity.node.canonical
  weight: 100

Everything shows up and looks/works the way I want it to.

The problem is that I cannot seem to figure out how to limit that link/view to only show and work when on the edit page for an instance of content A. It shows on EVERY node edit page.

I've tried the following and did not seem to get anywhere:

trying to hook into hook_local_tasks_alter in my_module.module
custom RouteSubscriber Plugin

In D7 I was abel to accomplish this with a hook and access callback:

function my_module_menu()
{
    $items = array();

    // Single sync functionality
    $items['node/%node/related_B'] = array(
        'title' => 'Related B',
        'page callback' => '_B_page_callback',
        'page arguments' => array(1),
        'access callback' => '_B_access_callback',
        'access arguments' => array(1),
        'type' => MENU_LOCAL_TASK,
    );

    return $items;
}

function _A_access_callback($node)
{
    if($node->type == 'A' && user_access('administer nodes'))
    {
        return TRUE;
    }

    return FALSE;
}

I solved this. I mentioned that I had tried hook_local_tasks_alter when I should have been using hook_menu_local_tasks_alter

/**
 * Implements hook_menu_local_tasks_alter().
 * @param $local_tasks
 * @param $route_name
 * @param RefinableCacheableDependencyInterface $cacheability
 */
function mymodule_menu_local_tasks_alter(&$local_tasks, $route_name, RefinableCacheableDependencyInterface &$cacheability)
{
  if ($route_name == 'entity.node.edit_form') {
    $route_match = \Drupal::routeMatch();
    $node = $route_match->getParameter('node');

    if ('A' != $node->bundle()) {
      unset($local_tasks['tabs'][0]['my_module.related_B']);
    }
  }
}


drush installing drupal through root ssh is causing 500 internal server error I have installed the drupal 7 using the root ssh user. The overall installation process seems ok within ssh. I have even downloaded and enabled the modules through drush. But when I tried to open the site on browser its throwing 500 internal server error.

I used the same process with out any errors when I grant a jailed shell access to the hosting account and login through their cpanel id in ssh.

But for the ease I want to install drupal through root ssh so I don't have to open multiple putty windows to manage multiple accounts.

Thanks to Matt C from Known Host who helped me resolving this issue. Sharing his reply below so others can be benefited.

  I've run the fix permissions script and it looks like all files and
  directories are set as they should be. You can find the script in
  /public_html/fixperms.sh. I've also provided you with a link for
  fixpermissions:

  http://boomshadow.net/tech/fixes/fixperms-script/


How to get remote webpage content with drupal http request? Would love to see some examples on getting remote webpage content with drupal http request. I have plenty of examples easily with Google with curl, but yet to find one with this drupal function.

Also, would CURL be better for getting remote content?

First, you can read the documentation about drupal_http_request() its pretty well documented and it will help you.

But for simple application, you can just do it like that.

<?php
$result = drupal_http_request('http://google.com/');
if (in_array( $result->code, array(200, 304))) {
  // Use $result->data for the content
}
else {
  // Error $result->code
}

// Also you can see all content from $result with
// if you had installed Devel Module and enable it
// dsm($result)
// or simply like that drupal_set_message('<pre>' . print_r($result, 1) . '</pre>');


It doesn't work without public_html symlink I have just updated to Ubuntu 20.04 so have a fresh install of everything.
I have a working Drupal 7 site I'll call mysite.
I have Drush-launcher installed globally at /usr/local/bin/drush
The file structure of the site is the following.

/var/www/mysite/composer.json (to install Drush 8.4.1)
/var/www/mysite/vendor/drush/drush/drush (local Drush 8.4.1 binary)
/var/www/mysite/web
/var/www/mysite/public_html (symlink to web)
/var/www/mysite/web/sites

Drush works with this configuration. drush status returns a full and accurate site description of about 15 lines.
If I remove the public_html link, the Drupal site runs fine but most Drush commands no longer work. drush status returns only the bare minimum of 7 lines as it does when it can't find the site. drush --version does return the correct version number either way and if I move the Drush 8 directory, all Drush commands return an error as expected. (This shows I'm still using the correct binary).
I have several Drupal 8 sites that are configured this exact same way (no public_html directory or link) and they work as expected.
I have searched in the ~/.drush directory for any reference to public_html and there are none related to this site. I have cleared the Drush cache. There are no references to public_html in my Apache config for the site. Searching isn't turning up anything useful.
I could just leave the public_html link in the filesystem but git wants me to add it or ignore which seems kinda silly.
What might I be doing wrong?

Solved it!
Thanks to @sonfd for making me think more about the composer installation. Look what I found in there:
"extra": {
  "installer-paths": {
    "public_html": [
      "type:drupal-core"
    ]
  }
},

I changed that from public_html to web and it works. Damn.


How can I use Drush in a project installed with Composer? I have installed Drupal 8.5 using composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --stability dev --no-interaction.
This command installs many files. I found drush-files in the root and the file vendor/drush.
It looks like Drush is available, but I have no idea how I can run drush. Trying command like "drush cr" was not successful. I get the following error.

-bash: drush: command not found.

I don't want to be able to use Drush from everywhere.
How can I use Drush only from my_site_name_dir?

Basically, you need to follow steps on http://docs.drush.org/en/master/install and get Drush installed globally. It's possible to invoke Drush installed within Composer context together with Drupal 8 indicating the exact path something like /path-to-website-home/vendor/bin/drush. However, if you want Drush available anywhere in the system then get Drush Launcher installed.

Here is direct quote from http://docs.drush.org/en/master/install:

  Optional. To be able to call drush from anywhere, install the Drush
  Launcher. That is a small program which listens on your $PATH and
  hands control to a site-local Drush that is in the /vendor directory
  of your Composer project. If you skip this step, run Drush from Drupal
  root via ../vendor/bin/drush. In that case Drush's bash integration
  and custom prompt won't work.

You might also want to read How to get Drush to work with Composer and What is the right way of installing Drupal 8?


"Administer Taxonomy" is needed to make a user select a term I need a user to select a term from a given vocabulary but the field is only available to a normal user if I enable "Administer Taxonomy" for them. Is there a way around this? Shouldn't I be using taxonomy for this?

You don't need to give an user the permission to Administer Taxonomy in order to use a vocabulary. Assuming you are using Drupal 7, as the name implies Administer vocabularies and terms it's a permission that allows one to edit and/or *delete a term from any vocabularies. It can also be specified per vocabulary.


Import from feed using a selector only if it has a given XML attribute I'm working on an import from an RSS feed that includes two types of XML <category> elements:

Subject Areas, e.g. <category>Economics | Social and Behavioral Sciences</category>
Keywords, e.g. <category domain="keywords">immigration, emigration, immigrants, international migration, poverty, immigration enforcement, asylum policy</category>

I want to import the Keywords as their own taxonomy field. I can write the YAML as follows, but it predictably imports both Keywords and Subject Areas:

source:
  fields:
    -
      name: keywords
      label: Keywords
      selector: 'category'
process:
  field_keywords:
    -
      plugin: explode
      delimiter: ', '
      source: keywords
    -
      plugin: entity_generate

How do I adjust the selector so it only pulls from the <category> element that includes the domain="keywords" attribute?

I figured this out with the help of an XPATH cheatsheet that shows how selectors I might have written to target HTML would transfer to XPATH values.

To only pull <category domain="keywords"> items, I can use category[@domain="keywords"] as my selector. The other set of <category> items don't have a domain attribute, so I pulled them separately using the selector category[not(@domain)].


twig problem, how to override base templates? I have installed Bootstrap and the Radix theme, and created a sub-theme, which is all working OK. But I am unable to get some of my twig files to override the base theme twig files...

The file themes/custom/mytheme/templates/page/page.html.twig contains:
{% embed '@radix/navbar/navbar.twig' with {

I would like to create a navbar.twig in my subtheme and use that instead of the standard radix one. Changes I make to themes/contrib/radix/src/components/navbar/navbar.twig will show up on my site (as this is what the embed refers to), but changes to themes/custom/mytheme/src/components/navbar/navbar.twig do not.

How can I change that embed line so that it includes the subtheme twig rather than the base? It's some kind of twig namespace? I have not been able to figure out where it is defined.

You can't. Create your own page.html.twig instead and use {% embed '@my_subtheme/navbar/... %} in there.

Use the machine name == directory of your subtheme for @my_subtheme. Only lowercase, digits and underlines are allowed for machine names. The Twig file must be placed below the templates subdir, but do not include templates/ in the embed string


Adding another date using the date repeat API I'm using the Date Repeat API in Drupal 7 to create an interface for a user to add in a recurring event. As it comes out of the box, it only allows for one date, then you have to save the node and re-edit. I've commented out the date_form_field_ui_field_edit_form_alter() in date.module which hides the multiples values option which I thought would allow the associated API to show the 'Add another item'  button. When I go into the 'manage fields' form in the Content Type, I've set the form to 'unlimited' values and saved it. However when I load the content type, the normal date which still has the 'Add another item ' button but the recurring date time does not.

I'm trying to add this since the event that it is attached to might well have a second recurring time for that event, for example it happens every Monday and every second Wednesday. Whilst I am aware that you can do this through saving and re-editing, from a UI perspective it would easier to allow a user to add more than one form of recurring event if needs require.

I'd be grateful for any guidance in solving this issue. Thanks.

Update: I've been doing some more digging and it appears that the 'repeat' code is a form linked off the date_request_api, but I cannot see why the field created in the Content Type admin UI does not appear to pick up on the multiple values setting.

If you select the repeat option in the field configuration, the Date module then declares to the Field API that it handles multiple values. There is a lot of discussion about it on drupal.org but sadly no patches for Drupal 7.


user not logged in php file I want use drupal functions in php files,I did it with below code

$path = $_SERVER['DOCUMENT_ROOT'];
chdir($path);
define('DRUPAL_ROOT', getcwd()); //the most important line
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Its ok and good fine, after this all drupal function exist,but my problem is here
when user logged in before this page when redirect to this page it not know as logged in user (it know as anonymous user ), how can have logged in user in php file ?

I try  drupal_session_regenerate() after below code but nothing happened, how can solve this problem?

This forum post on d.o explains what may be your problem.

You need to:

  Set $cookie_domain='example.com'; explicitly in your settings.php file.

According to the post, Drupal keeps a long session ID string in a cookie, and without a proper cookie domain, the current user is anonymous.


How to send forget pass email programatically? I implemented Decoupled Drupal in one of my projects, one of the features I need to implement is a forget password feature. So I created a custom route to listen to reset password requested.

I know I can create a reset password URL with user_pass_reset_url(); I can generate this link and programmatically set the email to that user, but I am looking for a service or Drupal core functionality to achieve this job.

How can I programmatically send a reset password email?

With  some reverse engineering on core user module  the solution is :

    $name = \Drupal::request()->get("name");
    $langcode =  \Drupal::languageManager()->getCurrentLanguage()->getId();
    // Try to load by email.
    $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('mail' => $name));
    if (empty($users)) {
        // No success, try to load by name.
        $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('name' => $name));
    }
    $account = reset($users);
    // Mail one time login URL and instructions using current language.
    $mail = _user_mail_notify('password_reset', $account, $langcode);


How to remove non existing page? I have this page where I've put block views on it but I can't seem to remove it. It's not in the menu items.

I don't know what to show you here, so please if you need screenshots ask me.

Examples:

Ex 1

Ex 2

Example 1 is node 5 (http://erlinevanhijfte.be/node/5). go to it and delete it.
Example 2 is node 102 (http://erlinevanhijfte.be/node/102). go to it and delete it.

To find the node I just looked at the page source which has a shortlink meta tag which shows the node id and also the body tag has a class which shows the node id


CCK checkboxes with no labels I'm currently creating a form where the user is supposed to check a (sometimes large) number of checkboxes. The problem is that I only want the checkboxes visible, not their label (or key) while the user is filling out the form. Is this possible?

Currently it looks like this:

[ ] label
[ ] label
[ ] label
etc.

I'm aiming for:

[ ] [ ] [ ] ... [ ]

I'm using Drupal 6.22 with CCK 6.x-2.9. Other related modules in my form that will interact with the checkboxes are Conditional Fields 6.x-2.0 and Multicolumn checkboxes/radios 6.x-1.6

Any help is appreciated. Thanks in advance.

you can use visibility:hidden; (and height and/or width 0px). I use visibility:hidden; when display:none is not useful (issues of inheritances of CSS, or maybe still you can need the values of the hidden elements).

Other suggestion. I have several forms that use lots of checkboxes, so I use Vertical Tabs http://drupal.org/project/vertical_tabs to divide the forms in several tabs, to show only one group of checkboxes per tab. So here is not necessary to remove labels of checkboxes.


How to add another html tag (i.e. span) before the field value renders using hook_preprocess()? I have a field (field_txt) that renders properly, but now i want to add a  tag around it so that i can style the background color of it. How would this be possible using the preprocess field hook?

Output

some text value

Desired Output:

some txt value

Not sure how it would be done with a preprocess hook, but an alternative would be to instead copy field.tpl.php into your theme, rename it according to the convention of field-name-[field_name], and simply add the  and  elements at the appropriate points in the template, like so:

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

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

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

            <?php endforeach; ?>


YouTube thumbnails - options for adjusting interface widgets and behaviour when clicked? I wish to add YouTube videos to my site as links - I want to use a thumbnail of the video. I'm not concerned with which thumbnail used (as discussed here: How to control preview image in Youtube)

What I am concerned with is how the play etc. buttons look on a thumbnail (i.e. everything reduced in size from how it would appear in YouTube).

What options do YouTube themselves offer? And what about 3rd-party solutions?

Facebook for example does this quite well - the thumbnail is not too cluttered and will expand when clicked onto to a usable size to view the video at a reasonable size on the same page (an example of my requirement for behaviour when clicked).

Any examples of such customisations on Drupal sites, please? Thanks in advance :)

I recommend the Video Embed Field module, it's pretty new but under active development. It will just show the thumbnail and when you click it load the video player page.

However, they are working on a lightbox integration (video plays in a popup modal) and you might want to suggest the "Facebook player functionality" as a new feature to them.


How to implement hook_views_query_alter? I used this topic before asking question but even if the problem is very very closed, the answers given did not work for me.

So I need to alter the query of one of my views in drupal 7. I created a new module called for example 'mymodule'. This module contains

.info file.
.module file.
.views.inc file.

My .module file contains the following. Note that my .views.inc file is located at the root of the module directory. I also checked that my views api version is 3 :

function modulename_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'modulename'),
  );
}

My .views.inc file, which is at the root of the module directory contains the following :

function modulename_views_query_alter(&$view, &$query) {
dpm($view);
watchdog('error title', 'error message');
echo 'TEST TEST';
die('test');
if ($view->name == 'my_view_name' && $view->current_display == 'my_display_name') {
    unset($query->where[1]['conditions'][0]);
    unset($query->where[1]['conditions'][1]);
 }
}

I can't see what I am missing trying to implement this hook but it never go into the views_query_alter function (I cleared the cache before trying). I think I've followed all advices given in the link provided above.

Any help would be appreciated.

.views.inc file is to separate the views alter logic.

hook_views_api to add the mymodule.views.inc file which can be with path your-module/includes/views or at the root of your module.

You also can use mymodule_views_query_alter at mymodule.module file which should work fine.

Please remove the cache after applying the changes.


Returned content not displaying I have created a custom page which has a db query to return content, which is using the pagerdefault extender on a Drupal 7 install.

However when I return the content the pager shows but not the content.  This is the code after the query:

$content = array();
foreach ($result AS $events)
{
    $content[] = '
' . $events->type . ' - ' . $events->nid . ' - ' . $events->tutorial_start . $events->event_start . '
';
}
$build += $content;
$build['pager'] = array(
    '#theme' => 'pager',
    '#weight' => 1,
);
return $build;

I can see the $content rows if I dsm $build, but not display them on the page.  How do I render them on the page?

There are two things you should know to make it works:

Your query should extend PagerDefault.
Element inside content should be Rendered Array

here is a working example adjust the code to your needs:

//- Build array
  $build = array();
  /**
   * @TODO: adjust the query to your needs.
   */
  //- Prepare the Query to Extend PagerDefault
  $query = db_select('node', 'n')->extend('PagerDefault');
  $nids = $query
    ->fields('n', array('nid'))
    ->condition('type', 'page')
    ->condition('status', 1)
    ->execute()
    ->fetchCol();
  if (!empty($nids)) {
    $nodes = node_load_multiple($nids);
    $content = array();
    foreach ($nodes as $event) {
      //- Prepare the content
      $content[] = array(
        '#type'   => 'markup',
        '#markup' => '
' . $event->type . ' - ' . $event->nid . '
',
      );
    }
    //- Add Content to the build
    $build += $content;
    $build['pager'] = array(
      '#theme'  => 'pager',
      '#weight' => 5,
    );
  }
  return $build;


It is possible to have an action for the condition rules? I have several conditions that are called in rules_condition_info () and wanted to have an action for each, for whenever a function returns true, it is called an action. I know it's probably possible, but how do I tell the action you want to perform a certain action for a certain condition ... thanks

Events, conditions and actions are bound together in a Rule. So to match them up you need to define them in your Rule. I am assuming you want to create a Rule programmatically to go along with your hooks?

You can define events, conditions and actions, as you say with hook_rules_event_info(), hook_rules_condition_info() and hook_rules_action_info(), but to create a default Rule, you'll need to use hook_default_rules_configuration(). It is recommended you put the hook implementation in MODULE.rules_defaults.inc to optimize the memory footprint.

For further details on how to use the hook, see Default rules in the Site Building Guide, and look at the default Rules the module provides.

Personally I would recommend that you build your Rule through the UI and featurise, or export it as a Rules string and then import it like so:

function MYMODULE_default_rules_configuration() {
  $items['test_rule'] = entity_import('rules_config', 'EXPORT STRING HERE');
  return $items;
}

That will save you a lot of pain.


Drupal 7 returning empty array because of the database connection I am able to connect to the remote database and fetch the results when I am using core PHP-MySQL connection.

But Drupal 7 returns empty array when I am using the same remote database connection. The local database is working fine.

Below is my database connection in settings.php

$databases['default']['default'] = array (
      'driver' => 'mysql',
      'database' => 'test',
      'username' => 'test',
      'password' => 'test',
      'host' => '*****',
      'port' => '3316',
      'prefix' => '',
);

When I am accessing my site, it is just returning Arrayas output. Is it a problem with my database user permissions or should I make any changes in Drupal database settings with port?

I resolved it. The problem is not in the database connection. I cleared the cache table in the database and it started working fine.

Earlier, I set the option 'Cache pages for anonymous users'. May be because of this, it didn't give the output.

Thanks for your answer.


LDAP Feeds example not importing new users - Undefined index: count in FeedsLdapEntryParser I followed the LDAP Feeds example from the documentation and the query test returns the user fields just fine, but after launching the cron job manually I get "There are no new users." + notice:

  "Notice: Undefined index: count in FeedsLdapEntryParser->parse() (line
  20 of
  /var/www/html/drupal/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc).
  LDAP Users Imported Successfully."

I triple checked my configurations, as well as the mapping which got unique targets for both User name (name) and mail. I also posted in the drupal module issue as I would think importing users via LDAP is a very much needed function.

Has anybody been successful importing that way or any idea why the count is making issues?

FYI my LDAP Query Results: count=1574. Could it be limited to certain amount of user entries?

Not sure what exactly resolved this but basically I added GUID as a unique field with a unique number and while manually running the cron job /admin/config/system/cron didn't add the users,

after I went to /import/ldap_data_to_user_data and scheduled the LDAP query for import it worked.

Now it also syncs after I run them manually. Not sure what i did wrong or was missing, slightly confused but happy :)


Programatically create nodes, taxonomies and relationships via exisiting database I have a client that wants a Drupal port. They have a MySql DB with a small built by hand backend. The data structure is about standard in terms of a business organization.

People

Department
Specialty
Location
Etc

How can I create taxonomies as well as nodes from a MySql Script from the old database?

http://timonweb.com/how-programmatically-create-nodes-comments-and-taxonomies-drupal-7 - only thing to note is making sure the taxonomy terms don't exist before you add them, which you can easily do with a function like this (recently wrote this for a project)

function taxonomy_import_add_or_get_term($term, $vocabulary) {
  $tid = taxonomy_get_term_by_name($term, $vocabulary->title);
  if (count($tid) > 0) {
    $tid = array_shift(array_keys($tid));
  }
  else {
    $term_object = new stdClass();
    $term_object->name = ucwords(strtolower($term));
    $term_object->vid = $vocabulary->vid;
    taxonomy_term_save($term_object);
    $tid = $term_object->tid;
  }
  return $tid;
}


How get Superfish to display on mobile device? I installed the Superfish Module and Library and it works on a desktop/laptop/tablet. It collapses correctly when I re-size the screen. But it won't display at all on a mobile device. I tried different settings on the Config page and tried adding the recommended code in html.tpl.php:
meta name="viewport" content="width=device-width, initial-scale=1.0"
I enabled SF-Smallscreen with the jQuery sf-Smallscreen plugin. Made sure it was weighted to appear at the top of all the blocks.
Still no luck.

My bad, I discovered my .css for the page was HIDING Superfish. Removed the offending code and Superfish on mobile works fine.


How can I get a list of content types with drush? How can I get the existing content type list with drush? This will allow me to quickly produce a list.

I've tried with:

$ drush @d6 @sites genc --types

But I need the devel_generates module enabled for this.

  Command genc needs the following module(s) enabled to run: devel_generate.

List of names:

drush sqlq "SELECT name FROM node_type;"

List of machine names:

drush sqlq "SELECT type FROM node_type;"

This works in D6 and D7.

The first line of the command's output will be name or type, respectively.
Pipe |tail -n +2 if you want to drop that first line.


How to sort feed aggregator's items in Views according to its category? How to sort feed aggregator's items in Views according to its category? I have two category : infographics (category id = 1) and others (category id = 2). I want to show items from infographics first and then others, regardless the timestamp. Any idea?

I'm hoping you've answered the question by now but just in case, I'll answer it for anyone who comes looking for it.

(Drupal 7)
If you only have two feed categories then after creating your aggregator view, add the "Aggregator Category: Category" field to your view. Make sure to check 'exclude from display' or it will show the category title in duplicates. Then, go up to your format settings of the view and add "Aggregator Category: Category" to "Grouping field Nr.1." This will sort and split your feed items into the different categories.

If you have several feed categories and only want to use two of them, you would add the filter "Aggregator Category: Category ID" with the values 1 and 2, or whatever the category ID is of the category you want. Then repeat the steps above.


How to create an iCal feed of non-Nodes? It looks like the Calendar/Dates modules don't add Views Display types directly. Instead you're apparently supposed to copy one of the default views that come with Calendar to access the additional displays. However, the default views are Node views and I want to create a view of non-nodes. For example, say I want to create an iCal feed display type listing the dates users created their accounts on the site. Is there a way to do that using the Calendar/Date modules?

I made several attempts to use the iCal functionality included with the Calendar module, but in the end I gave up on that idea. Instead, found an issue associated with the Views Bonus Pack, with code for adding iCal support to that module.

I made some modifications to allow me to use arbitrary Views fields in an iCal feed. I'm interested in hearing feedback on the idea, if anyone here gets a chance to try it out.

You can do this.

Make calendar module create an extra default view:

variable_set('calendar_default_view_options', array(
  array('name' => 'calendar'),
  array('name' => 'calendar_custom')
));

After clearing cache you should now have two calendar default views which are exactly the same.
Override the custom calendar view.

hook_views_default_view_alter(&$views) {
  if (isset($views['calendar_custom']) {
    $views['calendar_custom']->base_table = 'users';
  }
}

You can change the base table of the view, which is what Views will use to determine what you can query from.

Note this is example code and untested, but should work.


enable jquery ui effects in theme .info file Now I should add something like <?php drupal_add_library('system', 'effects.bounce'); ?> to my page.tpl.php to enable jquery ui effects to use in views_slideshow_cycle module.

is there anyway to do this inside theme .info file?

No, it's not possible to add a Drupal library through a module or theme's .info file. You can add single CSS/JS files, but not a defined library.

That means it's physically possible to download separate copies of system libraries and include them statically in your theme, but you should not do this. It's not the 'Drupal' way, and it makes things very difficult to maintain.

You're right in thinking the logic shouldn't be in your page.tpl.php file, it should rather be inside your theme's hook_preprocess_page function in the template.php file.

That way the library will be added in time to be included in the page, you maintain a nice level of separation between logic and display, and your theme will be protected in the case that core updates need to be applied to the libraries you're using.


How can I add meta tags for pages created with views in Drupal 8? I need to add meta tags for pages created using views in Drupal 8, I tried to use Metatag module. but it seems like there is no views integration on D8 version of this module. I also tried to install Meta tags Quick but it's not working!

is there any other alternatives? please advice.

Edit: I've already seen the answers for this previous question but all of them are recommending using the modules that I've already tried: Metatag currently doesn't support adding meta tags to pages created with views, and Meta tags quick doesn't work with current Drupal version 8.0.5

I think that this is still in development, one option is to configure the View as a block, then insert that block on a Page.  This won't work for all scenarios, but is a (poor) alternative.


Forcing together line items of the same unit type in Rooms and Commerce I am using Rooms and Commerce together as a booking system. One thing that bothers me is that it's possible for a customer to book let's say 50 pairs of roller skates, but Commerce will render each pair of roller skates as its own line item, which becomes insane as you have a long list of roller skate bookings when it could just print 50 x Roller Skates instead. Is there a way to force Rooms to recognize that items of the same unit type should be counted as several instances of one booking instead of several separate bookings?

Alternatively, does someone have a better idea of creating an equipment booking system that has checkout and payment integration? I also need the possibility to give discounts for multi-day bookings.

When editing the field display formatter for the product reference, there is an option you can select to combine like products in the cart:

If that's selected, then you can dig a bit deeper by looking at commerce_cart_product_add(). The logic to reckon a combination starts about a third of the function down. The biggest thing here is the comparison properties. Commerce uses at least two fields initially to determine if a product is a "like product": type and commerce_product. Then, it will add any fields that are exposed to the add to cart form, and finally you can then view or alter these fields by using hook_commerce_cart_product_comparison_properties_alter().

Effectively, it won't allow any products to be combined that do not sure the same SKU or unique properties that identify it.


CORS error in reading file I'm working on a headless website based on Drupal 8; I installed the CORS module and in CORS domain set *|*. Client side can read my view rest endpoint, but when client side try to load a file url returned by views rest result, I am faced with CORS error:

  XMLHttpRequest cannot load http://domain.com/sites/default/files/home-slider-slide3-audio/2016-11/tr_SaidNursi.mp3. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xx.domain.com' is therefore not allowed access.

How can I resolve this problem?

The webserver is Nginx.

As this file is public the HTTP request is not served by Drupal. You need to
configure your web server to send correct CORS headers. If you are using Apache and have mod_headers installed you can set these HTTP headers in .htaccess file.

http://enable-cors.org/server_apache.html


Fillable Fields in a View I want to submit several items with Views Bulk Operations - is there a module or method to add fillable fields to a view?

I think you need editablefield module. once this module is enable you can set any fields editable in your view. So when you visit your view page or block you can edit the field value there itself..
Nice Ajax is implemented in here, so it works very nice.. You can set it like double click to edit..

NOTE - I am not able to link the module with original URL at drupal.org so you can search for it in google with same name.


Entity Average Rating I have Player (Entity) which is referenced on a Match (Content Type).

Now I'd like to Rate (from 0 to 10) the player for every match and get the average rating, can someone point me to the right solution.

You can make a View and use the Views Aggregator Plus or Views Calc.

From Views Calc module page:

  This module adds simple calculations to a views table.

  You can SUM, AVERAGE, COUNT, MIN, MAX, or AVG selected columns. A plug
  in theme makes the view look more spreadsheet-like (right justifies
  numeric fields, shades calculated columns and rows, and underlines
  calculated rows).

You can found some screenshots here: How can I show average votes of fivestar nodes?


Specific role can only change status (active/blocked) of any user I've created a views page (holding all users information) for role ONE. Now I would like to give permission to that role he can change status (active/blocked) without editing the other fields (email, phone, username etc.) of the users.

I tried with Editable Fields module but it doesn't provide "editable formatter" in Users views field so it won't work for user's built-in field.

Is there a way to do so?

As I mentioned in the question,

  I would like to give permission to that role he can change status (active/blocked) without editing the other fields...

I've done it without giving permission (Administer users) to role ONE.

I had to do configurations between tree modules Flag, Views and Rules. I created new flag, get flag in views using relationship and the add two simple rules. That's all

Let me post the answer, may be someone will need in the future.

Above mentioned three modules should be enabled with their UIs.

Creating Flag

Go to /admin/structure/flags/add, create a new flag and choose User as Flag Type, example
After saving the Flag Type, fill next form like this, you may choose options as you like.

Creating Views

Now, create a views page/block as you like with showing Users category and your all fields you want to show and add a Relationship for the flag you just created (in my case it was "Block User").
Now, add a new field as Flag link in the views and add relationship if its already not and choose settings
Save the views

Creating Rule

We have to add to rules one for block the user and other for activate the user.

Block User

Add a new Rule /admin/config/workflow/rules/reaction/add and choose event "A user has been flagged, under Block User" and save
Add a condition using "Data comparison" and continue
Add value in data selector for flagged-user:status and continue
On next form, choose value as active and save
Now, add an action with Block User action and continue and add choose data selector for flagging-user and save

Activate User

There are same steps to activate users using rules. You just only to change event as "A user has been unflagged, under Block User", check the status as blocked instead of active and finally add action Unblock User instead of Block user.

All done...

Now, go to view the views you just created check if it works.

I hope it'll help someone.


Views argument to match single date with date range field My content type has a date field with an end date. So an example node has a date range, say from 2011-01-01 to 2011-01-30.

In my view, I want to add an argument/contextual filter that shows any nodes covering a specific day. So if the argument value is 2011-01-15, the node shows (it falls within its range). If the argument value is 2011-02-01, the node doesn't show.

In the Date (node) argument settings, I've played around with selecting both from and to date fields and the OR/AND settings, but can't find a way to do this?

It's a known bug, please see Multi-day events don't show up on day view of spanned days.


How to add a "continue shopping" button after emptying cart in Ubercart? This is really a weird issue. I get this on my ubercart page without any possibility for redirection:

One hint I'm eager to try is a drupal_goto function.

But how do I add this to which file to which line specifically?

For this, you can override uc_empty_cart() function with theme_uc_empty_cart(); which returns your custom message on empty cart page.

You can get continuous shopping cart URL from Store > cart setting using variable_get('uc_continue_shopping_url', '').

Example:

  // Default function from uc_cart.module
  function theme_uc_empty_cart() {
    return '
'. t('There are no products in your shopping cart.') . '
continuous shopping';
  }


Allow all users to view all groups (private or public) with Organic groups, but not private content I am using Drupal 7.25 (I need to update to 7.26) and organic groups 7.x-2.4.  I currently have public and private groups working.  I have two users (admin and a normal user).  I have a menu tab that opens the og list (/og-list) view which I want to list all groups (public or private)

Currently all public groups show up for the normal user.  The private groups are still not shown in this list to the normal user.  If I log in as admin they see all private and public groups.

How can I make private groups show up in this list to all users?  When they click on the group they shouldn't be able to view the content, just the group name and a subscription link.  If I type in the direct link to the group is gives me an an Access is denied page.

Thanks for the help!

List Private Organic Groups Publicly without giving access to the node page?
That post answered my question.  Thanks Damien Tournoud for posting the following answer:

  You can tell Views to ignore the access control of some of the Views.
  On Views 3.x, this parameter can be found under "Query Settings" /
  "Disable SQL rewriting", and is described as:

  Disabling SQL rewriting will disable node_access checks as well as
  other modules that implement hook_db_rewrite_sql(). The full nodes
  will stay private, so you should make sure not to link to them in the
  View so that your users do not land on "Access Denied" (403) pages.


Alternative to current_user I have modified user-picture.tpl.php the follow way:

$employeeid = token_replace('[current-user:field_employeeid]');
?>
<?php if ($user_picture): ?>

    <?php print $user_picture; ?>

<?php elseif ($employeeid): ?>

    <img src="../../sites/default/files/pictures/<?=$employeeid?>.jpg"/>

<?php endif; ?>

by adding a token_replace to manage the current-user avatar for a company directory. I have left the original options in place because there is the possibility for non employees to be logged in.

THE PROBLEM:

The above code works, provided you are the current user, I need the employee avatar to show for everyone. I have tried replacing

curent-user:

for

user:

with no success. The whole reason for this is so that the employee avatar is automatically pulled from an IMCE managed folder and NOT left up to the employee to "get creative".

Any constructive thoughts or suggestions would be appreciated. Thanks!

SOLUTION:

if (isset($account->field_employeeid['und'][0]['safe_value'])) :
    $employeeid = $account->field_employeeid['und'][0]['safe_value']; ?>

        <img src="<?=base_path()?>sites/default/files/pictures/<?=$employeeid?>.jpg"/>

<?  else: ?>

        <?php print $user_picture; ?>

<?  endif; ?>

i would say remove the if/else and only leave the else code, as you never want to show $user_picture

$employeeid = token_replace('[current-user:field_employeeid]');
?>

    <img src="<?=base_path()?>sites/default/files/pictures/<?=$employeeid?>.jpg"/>


Remove HTML Markup from YouTube RSS Feed Import Drupal newbie here- using D7 Commons on a WAMP Development setup (for now).

I am importing an RSS feed from YouTube (using Feeds & Media: YouTube modules). It's working great, except that the description text is inserting all the  markup tags in the description text. I have tried setting the field text to simple text and filtered html, but neither eliminates the markup tags.

Q: Is there a way to import the description text without all the HTML markup tags?

Thanks guys!

The simple answer is to configure the Text format setting Node Processor section of the Feed Importer found at admin/structure/feeds/[importer name]/settings/FeedsNodeProcessor, but there has to be more to your configuration that may be impacting this.  HTML tags/brackets are not allowed in the description of YouTube videos.

So I'm not even sure what HTML you are referring to.  I'm only aware of 3 options to get access to a list of YouTube videos formatted as RSS.

1) https://gdata.youtube.com/feeds/api/users/UC194cPvPaGJjhJBEGwG6vxg/uploads?v=1

2) https://gdata.youtube.com/feeds/api/users/UC194cPvPaGJjhJBEGwG6vxg/uploads?v=2

3) Using version 3 of the API as described in https://www.drupal.org/node/2181067.  That configuration requires OAuth.

In option 1 and 2, replace UC194cPvPaGJjhJBEGwG6vxg with account name you want a feed for.  In both those options, the description text is in the element...

 <media:description type='plain'>

That element cannot be mapped with just Feeds, Media and Media: YouTube.  You'd need something like https://www.drupal.org/project/feeds_mediarss

There may be another way to access the RSS, but without knowing what you are using it's impossible to provide a better answer.  As long as the Feeds Parser and Processor acknowledge the text format setting in the Feed Importer, the resulting nodes should only have plain text in their body fields.


Disable creating new taxonomy terms in term reference field I need to limit the user to the already create terms through admin/structure/taxonomy/VOCABULARY/add in auto complete mode, But when the user types new terms it will be added to the list. How do I can limit the user to the terms list?

The content taxonomy module adds additional functionality to prevent new terms with the autocomplete widget.

  D7 and Content Taxonomy

  The module provides extensions to Drupal's
  core Taxonomy Term Reference Fields. At the moment, following
  extensions are available:

  Parent term selector in the field settings (for options lists)
  Options for new terms in autocomplete (Autocomplete Deluxe widget supported as
  well):

  Allow and insert new terms (default behaviour)
  Allow and insert new terms into a separate vocabulary
  Deny any new terms


Page scroll issue when using dropdown menu I am using a view in this page, and using sexy exposed module for filter criteria.
The page shows the horizontal scrollbar. How can I get rid of it?

You could hide it with CSS using body { overflow-x: hidden; }.

It would be better to figure out why the scroll is happening, but it's hard to troubleshoot that without having access to your site.


Trouble theming poll block in Drupal 6 I wanted to be able to control the layout and containers for all elements (choice,title,vote etc) inside my poll block and decided to add my own template for the same.

Like any noob, I checked the block with devel and got the block template file,preprocess methods used (in my case poll-vote.tpl inside drupal core poll module and the template_preprocess_poll_vote inside poll.module) and the candidate file name for the template as poll-vote-block.tpl.php inside my themes directory (sites/all/themes/my_theme) and in the theme's corresponding template.php used the preprocess function as follows:

function my_theme_preprocess_poll_vote(&$variables) {
  echo 'Im in';
  $form = $variables['form'];
  $variables['choice'] = drupal_render($form['choice']);
  $variables['title'] = check_plain($form['#node']->title);
  $variables['vote'] = drupal_render($form['vote']);
  $variables['rest'] = drupal_render($form);
  $variables['block'] = $form['#block'];
  // If this is a block, allow a different tpl.php to be used.
  if ($variables['block']) {
    $variables['template_files'][] = 'poll-vote-block-custom';
  }
  print_r($variables['template_files']);
}

Initially I set the template_files value as 'poll-vote-block' and it didn't seem to be affecting the block, which i confirmed with devel again.

I printed the echo message to ensure the preprocess was called and it did print it. I renamed the template_files (and the template file) and printed it to get the following:

Array ( [0] => poll-vote-block [1] => poll-vote-block-custom )

I once came across theme templating in drupal docs that preprocess methods are not necessarily overridden but placed in a queue... to me it appears that my preprocess method's tpl file is set with lower priority and hence unable to override. Hence I'm unable to fulfil my requirement of theming the poll block

It'd be nice know if I'm mistaken with this conception and hope someone would provide me some insight on this to get my problem solved.

Thanks in advance!!

Edit

The problem was finally solved. I created a block-poll.tpl.php file and was then able to override the default poll-vote.tpl.php with my preprocess method and poll-vote-block-custom.tpl.php.

Apparently just like the case where one needs block.tpl.php for his block-module-delta.tpl.php to override a default functionality this might've been my case.

Marking jimajamma's answer as solution as it proves to be a good documentation and reference material worth being a wiki for Drupal theming for novice developers.

Cheers!!

If all you are just trying to change is the layout of the form, and not the data contained in it, all you should need to do is change the CSS for the various wrappers.

In this example, that would be looking at

      <?php if ($block): ?>

<?php print $title; ?>:

      <?php endif; ?>
      <?php print $choice; ?>

    <?php print $vote; ?>

  <?php // This is the 'rest' of the form, in case items have been added. ?>
  <?php print $rest ?>

so, if in your theme CSS you added

.poll {
  color: red;
  background-color: blue;
}

this block would now be in red and blue.

and if you added

.vote-form {
  border: 2px solid green;
}

then the form would have a border of green.  etc etc etc.

Now, if you need to change things up more, add some more divs or change their order, etc, you can just copy the standard poll template to your theme directory, refresh your caches and drupal will pick it up and override the one from poll itself, no need to name it anything different.


Memcache Admin not showing up in Modules I am updating a Drupal 6 installation to support memcached. After installing the memcache plugin, and configuring it with the following in settings.php, I cannot seem to access the Memcache admin page like I can on Drupal 7.

$conf['cache_inc'] ='sites/all/modules/memcache/memcache.inc';
$conf['memcache_servers'] = array(
  'ELASTICCACHE URL (Left out Intentionally)' => 'default'
  );
$conf['memcache_bins'] = array(
  'cache_page' => 'pages'
  );

I checked in modules to see if it was enabled but I do not see it there at all. All I can see is the memcache module without memcache admin.

Any suggestions?

The Drupal 6 version of memcache requires enabling the Memcache Admin module:

Once this module is enabled, there is an option at admin/settings/memcache to display memcache statistics on a page-by-page basis:


How to highlight only unpublished nodes in views result I have a node view with bulk operation style which is available for only admin role.
I would like to hilight only the unpublished nodes. It doesn't matter if just one of the fields or whole row of those nodes are hilighted.

I suppose I need to add special css class to unpublished nodes but how can I do that?

in your views add fields:

Node: Published, options "Label" empty, tick "Exclude from display",
"Output  format" choose "True/False"
Node: Title, option "Rewrite the output of this field" write [title]
Make css class ".false {color:red;}" for "unpublished" in your theme .css file

make 2 and 3 to your vbo fields, add "Node: Published", and rearrange to be first top field


Views 3 Exposed Filter AJAX HTTP Error Relevant modules & themes:

zurb_foundation-7.x-4.0
views-7.x-3.11
jquery_update-7.x-2.6 (front-end using 1.7 and backend using 1.5)

I have an exposed views filter on the front page that is auto-submitting when the dropdown field changes. I'm using Zurb Foundation base them (v4) along with the 'custom' field style. Here's what my view and filter looks like:

When I choose another option, I get this:

The weird thing is that watching views/ajax with a debugger, Drupal generates a proper response but jQuery presents the error alert even before the debugger acknowledges the debugging request. There is no "error" showing up in the Drupal or Apache logs. Once you click "OK" the page refreshes and the block shows the proper information based on the date selected.

So in this particular problem, what was actually happening was a double-posting of the Ajax submit handler. The first call was being interrupted and it was coming back empty. Removing the extra submit handler fixed the problem. This was directly related to the use of Zurb's custom form fields and a couple of browser issues that caused me to believe that the submit handler was not firing, but indeed it was.


Can't track why Boost-Crawler doesn't work I use Drupal 7.38 and Boost x - 1.0.7, and I Can't get the Boost Crawler to work... Boost itself is working fine (verified formation of cached webpage files at root/cache/...).

Seemingly, I did all I need to active the crawler submodule:

I enabled the module.
I went to Admin > Configure > System > Boost > Crawler, and ticked the checkbox to enable the crawler to run on cron.

After I did these stages, I ran Cron and went to root/cache/... and found only 3-4 cached files that where created by anonyous surfing either way... If the crawler module was working I guess I should have seen at least 60 cached-webpages there.

Since I'm not yet a programmer I have no idea how to even start dealing with this problem. The least I can do is to put here a print screen of my Recent log messages... I could paste everything seem relevant to you from there...

I very much need this submodule to work, please help!,

What you're seeing may be correct behavior. Boost Crawl (a submodule but without its own drupal.org page) is careful to warn that; "Minimal crawler - expires and regenerates pages only when content is edited and on next cron run" [Emphasis added.] SO, it will track content that you have edited, not crawl the site and thereby refreshing the page cache.

Enabling Boost and boost crawl on my site, and then running cron (using drush -v cron to spy cron output) I essentially saw what you saw, in my case just my home page. Running Xenu (explained below) triggered a populating of the boost cache for my entire site. Maybe this is what you were expecting?

If you want to refresh your site's boost cache index, check out either

xenu link slueth
httrack
or on Mac SiteSucker

You didn't ask, but each of these are invaluable web site QA tools as well.


How to change the display of my field? I have a field in one of my content types called lab_test_id. When Editors add content of that type they enter all the ids of the lab tests associated with that node. I need to be able to take that id, call that lab test database, and display the lab test fields I get back.

Can I accomplish that by changing the display of the lab_test_id field via hook_field_display_alter or should I find another way to accomplish that?

I think you can do this using hook_field_display_alter, however, I would personally prefer to create a custom formatter for the used field type. With the main advantage that you can save settings for the field formatter.

See the answers of How do I write an additional field formatter for an existing field for basic steps on how to create your own field formatter.


Change title of a content type I have a custom content type named 'product'. Every content of type product has a serial number of the product as the title.
But while displaying the title I want to override it from two of the CCK fields of the product.
Please take a look at this page.

I want to concatenate Manufacturer and Chip and display it as the title. I am a beginner in Drupal.

For altering the saved title, try auto_nodetitle module, it can do what you want there.

Download and install the module
Enable the module in Drupal
Edit the relevant content type settings ( Admin > Structure > Content types )
Set the Automatic title generation option, using field tokens for the field values

If you want to update the display only, then you can use a node.tpl.php template preprocess function

e.g in your theme template.php file, replace THEMENAME with your theme name.

function THEMENAME_preprocess_node(&$vars){
  $node &= $vars['node'];
  if ($node->type == 'product') {
    $text = $node->field_manufacturer[LANGUAGE_NONE][0]['value'] . ' ' . $node->field_chip[LANGUAGE_NONE][0]['value'];
    $vars['title'] = check_plain($text);
  }
}

Clear theme registry cache after adding a new preprocess function


I created a new content element: how do I print it out? I created a new content element for the page content type.
How would I print out the content of that text area in page.tpl.php?

Your question hints that you're not quite yet understanding some of the basics of the Drupal CMS. I'd recommend you do a little reading about nodes, content types and paths.

The page.tpl.php template is the master page template for your entire theme. That means every page output regardless of node type or non-node page altogether.

Your node.tpl.php template is the template for specific nodes. You can create node-MYTPE.tpl.php to control a specific node type.

For further details, see Theming Drupal 6 and 7, and Drupal 6 Template Suggestions.