Why Views is ignoring my field override, and printing fields regulary? You can see the question I am reffering here

I wrote a .tpl file to override the output of some fields.
I wanted the field will be printed with html like below (and succeed on doing so).
here is the output, when I am printing the field as a panel, through panels:

      <time datetime="PT3H45M" itemprop="prepTime">3 hours 45 min</time>

For some reason, when I am printing this fields regualry or with panels, the output is fine.
but, when I am printing them through a content-pane of views, the output is:

25 min

    Prep Time:

25 min

as you can see, views printing the field with "itemprop="prepTime" and without datetime="PT3H45M".

Why is that happening, and how can I fix it?

Thanks for your help!

UPDATE:
After I used @FiNeX tip, and checked the option "Use field template", it helped me solve some issues. Now the prepTime and cookTime fields are using the field template perfectly.

But, the totalTime template, which get the value from a computed field, print the output differently between views, and the regular way.

In the regular way the output is:

      <time datetime="PT1H35M" itemprop="totalTime">1 hour 35 min</time>

As you can see, the "datetime=PT1H35M" and the hour ("1 hour 35 min") are printed perfectly.

But, with views, the output is:

      <time datetime="P" itemprop="totalTime">5700</time>

As you can see, Views now is using the template, but the output of the template is:

datetime="P" and not  datetime="PT1H35M"
"5700" and not "1 hour 35 min" (by the way 5700 seconds are equal to 1 hour 35 min)

Why views is changing the output of the template after using it?

Here is the part of the template, that is creating the "Date time" and the time as I want to print it:

<?php
function time_to_iso8601_duration($time) {
    $units = array(
        "Y" => 365*24*3600,
        "D" =>     24*3600,
        "H" =>        3600,
        "M" =>          60,
        "S" =>           1,
    );
$str = "P";
$istime = false;

foreach ($units as $unitName => &$unit) {
    $quot  = intval($time / $unit);
    $time -= $quot * $unit;
    $unit  = $quot;
    if ($unit > 0) {
        if (!$istime && in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
            $str .= "T";
            $istime = true;
        }
        $str .= strval($unit) . $unitName;
    }
}

return $str;
}
 ?>

<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): ?>
    <?php $time = strtotime(render($item), 0); ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>>

          <time datetime=<?php print time_to_iso8601_duration($time); ?> itemprop="prepTime"><?php print render($item); ?></time>
    <?php endforeach; ?>

views renders fields with his own template. I imagine you're using a view which show "fields", right? On each field settings inside the view you can check the following option:

"Use field template"

If you select this option the view will use the field template instead of the view template.


How to customize exposed filter for date field? I have a view that shows a table of members. I would like to have an option to filter by "new members", let's say members that joined in the last month.

If I expose the field I get an input box with "-1 month" which isn't ideal.
It would be better to have a "select box" with "Any" and "New Members" options. A previous DA question didn't show an answer for this option.

Alternatively, links for "All Members" and "New Members" would work for me too. If I expose the field I can make the link work. But then I have to somehow hide the text field.

Any other solutions?

You can create your own form controls to send his values to exposed filters. For example, create your own select list inside a exposed filters template (views-exposed-form.tpl.php). This select list can have your desired options with respective values, according is needed in the exposed filter, for example:

<select id="edit-date" class="form-select" name="date">
<option value="-1 day">New members</option>
<option value="-7 day">Members within 1 week</option>
<option value="-30 day">Members within 1 month</option>
<option value="">All members</option>
</select>

Also, if you need a more complex behavior, you can alter view's queries with query_alter hook. This answer is an example of how to use query_alter with a custom select list.

I hope information be useful.


How do I create a rule to display a system message to users that an event is now over? I have an event content type with a date field. Is there a rule I can create that will display a system message to the user that "This event is now over." based on comparing the current date and the date in the date field?

EDIT:

Rules can be used for this.  Your message will be displayed using drupal_set_message()

Starting at the Admin screen;

Click through Configuration > Rules > Add New Rule
Give it a name and select Content is viewed in React on event. Click Save.
Under Conditions click Add condition

Select Data > Data comparison
Select node:type and click Save
Fill in for your content type and save

Under Conditions click Add condition (again)

Select Entities > Entity has field
Data Selector should have node
Field should have the field you're wanting to check. This should be a date field

Under Conditions click Add condition (again)

Select Data > Data comparison
In Data Selector chose your field. Mine was node:field-end-date
Click Continue.
Under Operator select is lower than
Under Data value select site:current-date
Click Save

Under Actions click Add action

Select the System > Show a message on the site entry.
Enter your Message, select the Message type (this is the drupal_set_message() status), untick Repeat message and click Save

Browse to your expired content to see your message.


How do do "Facebook style" image tagging? I couldn't find a module that would allow "Facebook style" image tagging (select an area of an image and tag it with a username, for example).

Any good starting points to build such a feature?

It's called "image annotation" if you want to search for it.  There are a handful of modules, but not sure how great they work or how often they are maintained.  This one seemed the best:

http://drupal.org/project/image_annotate


Javascript errors caused by  elements being wrapped inside a  tag I noticed that my site footer and a lot of <script> elements are wrapped inside a <strong> tag.
This is causing a lot of JS errors of the type:

Uncaught TypeError: Cannot read property 'permissionsHash' of undefined
Uncaught TypeError: Cannot set property 'StateModel' of undefined
Uncaught TypeError: Cannot set property 'AuralView' of undefined

How can I fix that?

I found out that the checkbox 'Trim this field to a maximum number of characters' was checked in one of my views which was trimming some HTML from the field content (closing tags) and causing the issue.

checking the option 'Field can contain HTML' fixed the issue for me.


How to share user and user profile in a multisite environment? Possible Duplicate:
  How do I create a multisite, sharing users and nodes?
  How to share user and user profile in a multisite environment?

My question was about the whole process to get the shared user in a multisite environment.
I didn't know how to start.

I found my answer here

http://drupal.org/node/547862

As the title says I would like to share user and profile table between multisites.

I have got the main domain like example.com and then I have two subdomain site2.example.com and site3.example.com with separate db.

My 'sites' directory is:

all

modules

themes

libraries

default

files

setting.php

site2.example.com

modules

themes

libraries

files

setting.php

site3.example.com

modules

themes

libraries

files

setting.php

I know how to create multisites with separate db, modules, themes and files, now I would like to know the whole process to create a multisite with shared user and user profile.
What I need to do?

Thanks in advances.

Edit settings.php -> $databases

$databases['default']['default'] = array(
  'database' => 'my_db',
  'username' => 'user',
  'password' => 'pass',
  'host' => 'example',
  'prefix' => array(
    'default'   => '',
    'users'     => 'shared_db_',
    'sessions'  => 'shared_db_',
    'role'      => 'shared_db_',
    'authmap'   => 'shared_db_',
  ),
  'collation' => 'utf8_general_ci',
);

Add any other tables as required in prefix array.
Have a look at settings.php as well it has lots of documentation on all these.


Userpoints: Require userpoint for being able to create a node? How would one go about requiring the user to have userpoints before creating a node?

Perhaps with some kind of Rules validation?

Cheers

There is a module in the userpoints_contrib project, which does exactly this.

You can combine it with userpoints_nc or a rule to also deduct points when a node is created, so that creating nodes costs something.


Problems primary links translate drupal 6 I have translate the link in my menu (primary links) in spanish, when i change the language from italian to spanish all the voices of the menu are translated except one ( the voice apartamentos) that is not visible but is right activated and setting as the other links.
Do you know something?

I flush all the caches and the problem dont exist!


Hide tab created by views if user has a specific role I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) {
    global $user;
    if (in_array('gerant', array_values($user->roles))) {
        $items['user/%user/infos']['type'] = MENU_CALLBACK;
    }
}

This doesn't hide the tab, but it works for other tabs -created by
other modules- like user/%user/contact.
I wanted this user still be able to see this tab in other users
profile.

To add more information

There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.

Finally it worked for me using hook_menu_local_tasks_alter(), thanks to drupal developers community.

function hide_tabs_menu_local_tasks_alter(&$data) {
  if (arg(0) == 'user' && is_numeric(arg(1))) {
    $uid = arg(1);
    $account = user_load($uid);
    if (in_array('gerant', array_values($account->roles))) {
      foreach ($data['tabs'][0]['output'] as $key => $value) {
        if ($value['#link']['path'] == "user/%/infos") {
          unset($data['tabs'][0]['output'][$key]);
        }
      }

    }
  }
}


Is it possible to hide fields on node edit form or split node edit form in two screens? I have a content type cFoo. This content type has e.g 10 fields.

I want:

user has page node/cfooxx/edit/screen1 and sees only fields 1,2,3,4,5
user has page node/cfooxx/edit/screen2 and sees only fields 6,7,8
user has no access to fields 9,10

I did a lot of reseach on this but it is not clear for me.

how to get the splitting of the standaard node/xx/edit url to edit/screen1 and edit/screen2?
On the front I use display suite so I can manage a display. Is there a module which can do this with edit forms as well?
If I use css, still fields of screen1 are processed in background of screen2 and the other way around. I do not want this because of possible errors in form validation. But suppose i need to do this... then the /node/cFooxx/edit url containts fields 1/2/3/4/5/6/7/8. So how to decide which css to apply when entering /node/cFooxx/edit?
If I use hook_form_alter how to identify screen1 and screen2?
Point 3 I can solve with field permissions module

You could use different modes on the two routes. Go to /admin/structure/types/manage/fooxx/form-display and there you can configure which fields you want see on which mode.

You can add new modes here: /admin/structure/display-modes

  Note: While Drupal 8 core already comes with "form modes", in Drupal 7 you need to install the
  flexiform module.


How can I override the field in my view? I have a view for a content type with a number of fields. For one of the fields (List, text) (node_field_type) I would like to override the output result. It can be either type_1 or type_2 . In the database the type is stored in node_field_type table in field_type_value column.

So in the settings of the field under "Rewrite results" tab I picked "Override the output of this field with custom text"

But it doesnt assign any class to html tag.
Could you please help me?

You need to have the field field_node_type called somewhere in your view to use it as a token in rewrite results for a field. Value that you're trying to use in rewrite results should be available within replacement patterns for the field you're trying to configure.


"Theme info" checkbox not showing on non-admin pages I'm using the Theme Developer module. When I enable it, the Theme info checkbox shows up in the admin pages, but it doesn't show on the non-admin pages (e.g. Home page). There aren't any JS errors from the console. What could I be missing to make it appear?

Apparently, someone wrote a module in the project to unset the default Drupal JavaScripts. Just had to remove that code to make everything work the way they should.


How to submit a custom form in drupal 7 I am new to drupal, but i have a requirement with form submission .For this i have created a static block . In that block some input types are there like dropdown menu, checkboxes radio button etc. When user clicks on preview button i am able to fetch the data into bootstrap modal dialogue box.So in that modal dialogue form, submit button is there.But when i try to submit the values from modal dialogue box those values are not posted. Those values sent to url.

For this i am using normal $_POST method.

I have placed this code in the block section like regualr php .

if(isset($_POST['sendtorfq'])
{
  print_r($_POST);
}

<form name="rfq_form id="rfq_form method="post">
  <input type="submit" class="btn btn-primary" name="sendtorfq" value="SendData">
</form>

But it takes form method as GET. and when i place the mouse on the submit button it shows
the url of that page like /process?name=somename&email=someemail.Every time when i submit the form values are posted to url . But not to post method. Please suggest me  where i was wrong?

I would strongly recommend the Entityform module.  Going with this module, would allow you to take advantage of the countless contributed modules that add fields via field ui. Like the most useful for you would be the Rules and Views modules.

Rules would be used to create custom conditional actions when your form is submitted and Views would allow you to create custom displays using form submissions.


Slideshow does not work in Safari or Chrome My slideshow block works in Firefox, but not in Chrome, Opera, or Safari. In these browsers, I just get the controls with no images. Note that the View page (attached) also dopes not show the image the preview in the other browsers.

Try putting your slideshow in the main content region and see if that works. Also, try setting a width in the css class associated with the slideshow.
Sd


I have 4 facets set to filter results by taxonomy terms but only one of the four filters work I'm using Apache SOLR with Facet API and am having trouble getting my facets to show. I have 4 facets that are set to filter results by taxonomy terms. Each filter uses a different vocabulary. For some reason only one of the four filters work. The other three don't even show up. Any ideas as to why this is happening?

Did you check the corresponding blocks for each facet are set in sidebar region (or where ever you want them to be?).


How do I place a block in a region, programatically? Why isn't my custom block rendering in the region I want? It shows in the content region, not my custom content_right region.

function bootstrap_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'some.path') {
    $block = \Drupal::entityManager()->getStorage('block_content')->load(12);
//kint($block);
    $block_view = \Drupal::entityManager()->getViewBuilder('block_content')->view($block);
    $variables['page']['content_right']['custom_block'] = $block_view;
  }
}

What am I missing?

You can try this, create an instance of a block plugin on the fly for the block content:

$block_content = \Drupal::entityTypeManager()->getStorage('block_content')->load(12);

$plugin_id = 'block_content:' . $block_content->uuid();
$block_view = \Drupal::service('plugin.manager.block')
  ->createInstance($plugin_id, [])
  ->build();

$variables['page']['content_right']['custom_block'] = $block_view;

But it's better to configure the block plugin in UI and build the configured block instead. For more info see this question Programatically render a block in a twig template


Fallback value for contextual filter, in case the "provided default value" does not exist I want to display a block on each page (nodes as well as pages created by Views) that displays links to nodes that are tagged with a certain taxonomy term.

How to decide which tag should be used:

{1} If the page is a node that references a taxonomy term:
use the referenced term
{2} If the page is a node that doesn’t reference a taxonomy term (= empty value):
use the term with ID 1
{3} If the page is not a node (= created by Views):
use the term with ID 1

I managed to get the links shown in case {1}, by using the relationship "Content: Taxonomy terms on node" and the contextual filter "Taxonomy term: Term ID" which uses the relationship.

I selected "Provide a default value" (Type: "Taxonomy term ID from URL" + "Load default filter from node page, that’s good for related taxonomy blocks"). So I can’t specify the default value here for case {2} and {3}.

Then I thought I could use the validation options somehow, but "Action to take if filter value does not validate" does not allow me to set a specific value in case the original default value does not exist.

How could I solve this?

tl;dr: I need something like: Take term ID from URL (via node ID), and if this gives no term ID, use term ID 1 instead.

Just set your contextual filter to return 1 when the value is not available like so:


Finding out template I'm working on this web site which I need to make changes to the heading part and I need to know which template or file is generating it so that I can add a slogan. My first attempt was using theme developer. However, it crashed the site so I had to disable it. Is there any other way I can track down the responsible template?

Drupal 7.0

You are looking for Theme developer module:

  Firebug for Drupal themeing. See the screenshot and screencast. Note that this module injects markers into the DOM to do its magic. This may cause some themes to behave erratically and less capable browsers may make it worse (especially IE)/. Enable it when needed, and disable it afterwards.

If it is crashing your website

You need to upgrade. You are at 7.0, current version is 7.31. You are 31 minor versions behind. And some of them was security updates. So you probably should upgrade anyway.


Which module facilitates looking up database schemas of custom content type? I am setting up some reports using DB API to query custom content fields, and rendering them in tables and charts. I am looking for a way to easily look up the names of tables and fields in the Drupal DB.

My Question: Is there a Devel-type module that provides an easy reference of the live DB schema?

Currently I'm using drush sql-cli and/or phpmyadmin, so the solution should be something simpler than that.

I think the Schema Module can handle that...

  Schema documentation: hyperlinked display of the schema's embedded documentation explaining what each table and field is for.

I confess I haven't tried it but the module page mentions

  the INFORMATION_SCHEMA database that the Schema module uses to inspect the database.

so I imagine it has the functionality you're looking for, plus inspection of the live db if you need it.

Or if you don't mind wading through a large krumo array you can always use drupal_get_schema()

dpm(drupal_get_schema());


Allow groups of users to edit a single Webform I need to enable groups of users to edit one Webform so that they can collaboratively complete a questionnaire. I am not concerned with two people editing at the same really.

I've seen mentioned the Organic Groups module and the OG Webform module to enable this but as far as I can tell it isn't suited to what I want to achieve.

The other option seems to be to implement hooks in the Webform module to override the user authentication but I'm afraid I wouldn't know where to start with that. How would you define the groups of users and then allow access to the forms based on those groups?

Any help would be massively appreciated!

If you can group those users in a role, you can use the Content access module to allow them to edit the webform.

Furthermore you can set content access settings per node, so you can limit them to be able to edit only that one webform.


How to display select query results using ajax in a form in drupal7 Please give me some solution for this. I want to display the Database select query results in a form using ajax in drupal 7.

Without specifics it's tricky to answer your question but here's a very basic example:

function MYMODULE_some_form($form, &$form_state) {
  $form['select'] = array(
    '#title' => 'Option',
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(1,2,3)),
    '#ajax' => array(
      'wrapper' => 'some-form-results-wrapper',
      'callback' => 'MYMODULE_some_form_ajax'
    )
  );

  $form['results'] = array(
    '#prefix' => '
',
    '#suffix' => '
'
  );

  // If the form has been submitted, build up your results and display them
  if (isset($form_state['values']['select'])) {
    $rows = db_select('some_table', 't')
      ->fields('t')
      ->condition('some_field', $form_state['values']['select'])
      ->execute()
      ->fetchAll();

    $header = array();

    $form['results']['#markup'] = theme('table', array('header' => $header, 'rows' => $rows));
  }
  else {
    $form['results']['#markup'] = '
The results will appear here when you change the dropdown option.
';
  }

  return $form;
}

function MYMODULE_some_form_ajax($form, &$form_state) {
  return $form['results'];
}

You might want to check out the ajax_example module included as part of the Examples module, it has a lot of code and comments that will help you understand what every piece of the above example does.


Can't edit permissions Drupal 7.21
For some reason I can't edit/add permissions for certain content to ANY roles anymore.
I first noticed this with one role and that had certain permissions missing.
Added the missing permissions and tried to save, but it always reverted back to before save.
I deleted the entire role and  it doesn't take any permission.
Other roles the same issue, can't add any additional permissions for create content even for r administrator (User1)

I experienced this under Drupal 6.x - it is possibly a similar experience on Drupal 7.x.

The Apache error log (/var/log/httpd/error_log or similar) may show something similar to the following:

... [error] [client ... ] PHP Warning:  Unknown: Input variables exceeded 1000.
    To increase the limit change max_input_vars in php.ini. in Unknown
    on line 0, referer: https://.../admin/user/permissions

To resolve add the following to php.ini

max_input_vars = 2000

Reload Apache per your operating system and increase setting if pain persists.


Compound key in database schema I'm trying to define a compound key for a custom database table.

My first insert goes through OK but the following inserts fail because the PID value is the same.

What I'm trying to achieve is a state where the uniqueness of each insert is determined by a combination of the PID, QID and UID values of each insertion.

The following is my schema in my install script:

function module_schema() {

  $schema = array();

  $schema['module_records'] = array(
    'description' => '',
    'fields' => array(
      'pid' => array(
        'description' => 'PID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'User ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'qid' => array(
        'description' => 'QID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'first' => array(
        'description' => 'First option',
        'type' => 'text',
        'length' => 255,
        'not null' => FALSE,
      ),
      'second' => array(
        'description' => 'Second option',
        'type' => 'text',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array('pid'),
    'indexes' => array(
      'uid' => array('uid'),
      'qid' => array('qid'),
    );

  return $schema;
}

You may define 'type' => 'serial' if you want to auto increment your primary key.


D7: $node->created property not available in mytheme_preprocess_block(&$variables) function? Hello I need to insert a formated date in a block template: block--delta-blocks--page-title.tpl.php

As I think this can be done using a preprocess function to set the $day, $month, $year variables:

function cybele_preprocess_block(&$variables) {
    $variables['day'] = format_date($node->created, 'custom', 'd' );
  }

But it seems $node->created is not visible here.
It works if I place it in:

function mytheme_preprocess_node(&$vars) {
    $node = $vars['node'];
    $vars['year'] = format_date($node->created, 'custom', 'Y' );
    $vars['month'] = format_date($node->created, 'custom', 'm' );
    $vars['day'] = format_date($node->created, 'custom', 'd' );

}

but not in _preprocess_block function. Can someone help me do that?
Probably I need to declare in mytheme_preprocess_page but the block template won't see from there either.

The important difference between the two code examples you're giving, is $node = $vars['node'];. You can only use the variables that are available inside the function you're writing. If you declare a function cybele_preprocess_block(&$variables), then the only variable you start with is $variables. In other words: inside that function, $node doesn't exist yet!

Sometimes, the current node is stored in the $variables array, so if it's in there, we can take it out again. That's what the line $node = $vars['node']; does: it creates a new variable $node and populates it with the value of $variables['node']. You do not have to put the node in a separate variable; you can also do this:

function mytheme_preprocess_node(&$variables) {
  $variables['day'] = format_date($variables['node']->created, 'custom', 'd' );
}

If the node is not available inside $variables (which I think is the case in _preprocess_block) you will have to load the current node. Fortunately that's rather easy in Drupal 7, because you can use menu_get_object. This will only work when viewing a node page.

function mytheme_preprocess_block(&$variables) {
  $node = menu_get_object();
  $variables['day'] = format_date($node->created, 'custom', 'd' );
}


Optimize CSS & JS breaks IE & FireFox (All Themes) Problem
Theme is not showing properly on my production server for individuals using Internet Explorer & Firefox after setting the CSS & JS Optimization options to enabled.  I initially thought the theme was broken for IE, however upon further review I realize the reason IE didn't work while CSS/JS optimization was disabled is because of Internet Explorer not handling more than 31 CSS files.

  To Help with troubleshooting I used the Site Documentation module to get all the info on the site, modules, etc. Here is the link to it.

Drupal Core: 6.22
Theme: 0 Point, Zen, Tao, PixtureReloaded

It is not a multi-site installation
It is on the same web hosting account as 3 other drupal
installations, the 3 other drupal installs do not exhibit the same
issue.

I used the Backup & Migrate module to copy the MySQL DB and used FileZilla to download the site/default/files/* folder(s) & files, site/all/modules, libraries, & themes files.  I restored the DB & sites/default/files folder to a test server.  Setting "Optimize CSS & JS" to enabled fixes the 31 css files problem for Internet Explorer and both FireFox and Internet Explorer are able to view the website theme as normal.

The absolute strange quandry here, is when I enable CSS/JS Optimization on the production server it breaks the theme for both IE and FireFox.  Chrome and mobile devices (android & iPhone) are unaffected.  I have not checked any other web browsers for issues.

I have listed the themes that I have specifically checked.  Where do I continue troubleshooting this from here?  I thought maybe changing the theme would fix it, however it has not.

Troubleshooting
Enabled the Optimize CSS/JS Files options by

Making setting the File System >> Public option.
Setting the Performance >> Optimize CSS/JS options to enabled.
Clearing the Cache and Rebuilding the Theme Registry.

Switched the Theme to PixtureReloaded (an adaptive theme) and repeated the steps above.

Switched to Zen and repeated the steps above.

Checked the file system permissions for sites/default/files to make sure there was read/write access and there is for owner/group/other

It seems that regardless of the theme I switch it to it does not fix the IE issue, and when I optimize the css/js files it breaks the website for FireFox users as well.

-- Edit 11/1/2011 1:30AM UTC --
As per suggested I re-encoded all the files in the theme from ANSI to UTF-8 without BOM.
Backed up the original theme folder, after taking the site offline
Uploaded via ftp the re-encoded theme
Ran update.php, cleared the caches, rebuilt the theme registry
Issue persists.

-- Edit 11/1/2011 4:57 PM UTC --
I also tried using the Garland, Mannilli, and Bluemarine themes with the same results (I tested this last night when I took the site offline).

-- Edit 11/1/2011 6:53 PM UTC --
I took the site offline, changed the settings to "Optimize CSS: Enabled"
Viewed Source for Chrome, FireFox, & IE9
I am able to click on the links for the CSS files and browse them, each css file is the same, and I did a DIFF/Compare of the  tag content and except for a session ID that ubercart uses for the shopping cart each head section is the same.

One possibility is that one or more CSS files have a Unicode BOM at the beginning.  The CSS optimizer that Drupal uses (at least the one in 6) doesn't work properly with these.  IIRC, the first rule gets mangled if it is the very first line in the file.

Switching the encoding with Notepad++ is the easiest way to fix this in you are on a PC.


META tags module description [node:summary] doesn't work I have a content type with title, image, body field (long text with summary). I use meta tag module and when I add in Description: [node:summary] or [node:field_body:summary] nothing appears in the meta description in view-source.

<meta name="title" content="..."
<meta name="image" content="..."

Title and image work, but not summary.

Does anyone have a solution?

I can confirm, that the token [node:summary] works in metatag. But only for the original "body" field with exactly that name. Did you change the field name? Because the original "body" field is not "field_body".


Update entity properties fetched with entityTypeManager()->getStorage I am loading all entity types I need to update like below

$current_fruit = \Drupal::entityTypeManager()->getStorage('fruit')->loadByProperties(['status' => '1']);

Then I update them in a way that I loop through the object and if particular value is matched I update some properties.

Thing is I am wondering is it possible to not loop through all of them, but just use some "magic" get method to find entity within loaded entities and then updated it, or is the foreach best method to do this?
Something like

$fruit = $current_fruit->name->getByValue("Apple);

and then I could just use

$fruit->set('price', $40);
$fruit->save();

You can actually use loadByProperties as that filter, you just need to extend your search:

$apples = \Drupal::entityTypeManager()
  ->getStorage('fruit')
  ->loadByProperties([
    'status' => '1',
    'name' => 'Apple'
  ]);

If you need to filter an existing, broader list, then just use foreach, array_filter, etc; Drupal doesn't have any special methods for it.


How to filter latest 10 days from the current date in Views I have created a listing page for News in Views. I wish to filter the news, just to show the latest 10 days from the current date. I wonder how to achieve this through Views.

You can set it using filter criteria. Look at the snapshot below.

Look at the Pist date (> -10 days),by adding the field post date in the filter criteria and setting to -10 days will give you the nodes created in last 10 days


Search on specific content Hi is it possible to make a search box which are searching only for some specific content.

it should be a search box that should look at titel, ingrediensliste, body, and who have made it.

You're looking for the Custom Search module.
This module alters the default search box in many ways. If you need to have options available like in advanced search, but directly in the search box, this module is for you.

Basic options
The module adds options to select:

which content type(s) to search,
which specific module search to use (node, help, user or any module    that implements search),
which input type to use (with Elements),
advanced criteria

For all these choices, there are options to switch between a select
box, checkboxes or radio buttons, and also customize the selector
label and the default - Any - text.
Advanced options
There are also options to:

change the default search box label,
add a default text in the search box,
add advanced search criteria,
change the default submit button text,
use an image instead of the submit button,
change the order of all the elements,
include some elements in a popup block,
add a filter to the results page,
show/hide basic and/or advanced search in the results page,
show/hide meta data in the results page,
multiple search paths

You can also achieve that by writing a custom module. Have a look at
Build a Drupal 7 Content Type Search Block in 5 Easy Steps


What is the Internationalization Views module for? In what kind of use cases would one want to use the Internationalization Views module?  I just discovered this module for the first time today, but documentation on it is sparse.

Since it is already possible to translate the fields and rewrites that are used in Views with the standard i18n module, what does this add?

Looking at the module code it seems to do the following:

Adds a Translate operation to the ctools export UI (see the i18nviews_ctools_plugin_post_alter() function in the module file).
Supports translation for views strings: title, header, footer (this is in the i18nviews_help() function).

The comment at the top of the module file is:

  This module translates some views strings on the fly using i18n string system

So I would guess the module is just providing internationalisation for some elements of the Views module that don't have it built in yet.


How can I add a flag for reporting abuse on private messages using hook_privatemsg_message_view_alter()? I have a flag on my Drupal 7 site for alerting moderators regarding potential abuse.

I want a link to this flag to be displayed next to the Delete and Block links on the view private message screen (messages/view) provided by the Private Message module.

By inserting the following code below the code for the delete link (line 769) in the latest version of the module, I can render the link correctly.

$author = $vars['message']->author;
$vars['message_actions'][] = array('title' => t('Report abuse'), 'href' => 'flag/confirm/flag/abuse/flag/block/' . $author->uid .  '?destination=user/' . $author->uid );

However, I don't want to hack the module; I want to add this code to a custom module.  hook_privatemsg_message_view_alter() appears to be the function for this, but I don't understand how to use it.  Simply inserting the above code and calling the function from within my custom module does not result in any errors but the link is not displayed.  What do I need to show the link?

EDIT: The solution need not use hook_privatemsg_message_view_alter(); if there is a better way that doesn't involve hacking privatemsg, I'd be happy to hear of it.

I really don't know why you don't like the answer by Rene.

Let me show a more detailed example.
You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':

You can edit Flag labels, link type and permissions here.
The result:

Please, feel free to ask questions.


Computed Field not showing I want to use the computed field in my drupal 8 website to calculate the charges for a parking system where I calculate the charge for a vehicle by taking the date of collection minus the date of parking, multiplying by the charge per day. total-charges=(collection-paking)*charge-per-day. However, even before I do the calculation, I tested to see if the computed field is working by assigning the $value='hello' and the assign the $disply_output=$value but its not being displayed in the content of the node together with other fields. Other things done to try to resolve this issue

Change the data type from varchar to text to int and others
Change the settings in the 'manage display' option of the content type. From toggling sanitize on an off, change display of the computed field from above to inline, etc
Resave the node by clicking edit and then saving the node, and even creating a new node of that content type after adding the content field.

Still not working.

After googling, most common solution, which works for drupal 7 guys is to uncheck the option to save the field in the database. But I dont see that option in drupal 8 so that I can uncheck it. Because I do not want to store the value in the database since It changes everyday a vehicle is not collected, so all I want is to calculate the value on the fly and charge the vehicle owner when collecting the vehicle.
How do I make the computed field even display a simple 'Hello World'?

I think it must be a bug, since the computed module is in alpha for drupal 8 at the time of this writing. With the help of Matt, we were able to print a simple 'hello' message by manually creating a new node. This new node will have access to the new computed field. I was using the devel module to generate content for nodes, which for some reason did not have access to the computed field. So if you are experiencing the same problem, set up your computed field, and then manually create a node, or edit and resave a node your previously created manually. That worked for me.


IMCE file browser doesn't list the files in the Directory path that are uploaded by FTP I installed IMCE and Filefield_sources modules to browse the files on the server. my website is on the localhost yet. the directory path of User-1 which is assigned to the administrator is set to <root>/temp_files but when I click on the browse file link in the add new content page it only displays files the are uploaded via IMCE file browser not the files I uploaded in the  Directory path. why ?

UPDATE:

my OS is Windows so I guest it is not permission related.

found it!
Instead of using Filefield_source module I should use the IMCE for FileField module, that's all. Details from project page:

IMCE for FileField allows users to select files from IMCE File Browser. It supports FTP uploaded files by automatically registering them as IMCE files thus making them usable in a FileField.
How to use

Go to your FileField settings page.
Check the box saying Allow users to select files from IMCE File Browser for this field


Domain override module in drupal 7 I have a main site with "domain access" module. It has 5 multilingual sub sites with subdomain(single database).
I want to publish content from the main site to the subsites. This is already working good with send to affiliates.
But I want some admins on the subdomain to edit some content and it should reflect on that subdomain only
i.e It should not update content in main site.In drupal6 I found module "domain override"
How I can acheive this in drupal 7

Use Node clone module and remove the domains for which you don't want to publish the content.

This is what Node clone modules does:

  The clone module allows users to make a copy of an existing item of
  site content (a node) and then edit that copy. The authorship is set
  to the current user, the menu and url aliases are reset, and the words
  "Clone of" are inserted into the title to remind you that you are not
  editing the original content.

And this is what Domain override module does:

  Provides an "Override" tab on node pages that removes the current
  domain from the node's domain access, clones the node, and publishes
  the clone to only the current domain.


Why is my Views row template not loaded? I am using Views 3.

I have created my view and get these theme suggestions:

As you can see I created a --presse-page.tpl.php file bold marked in the second block. It works fine, but I need to style only the rows. So I created a views-view-fields--presse.tpl.php file, but if I rescan the theme, it does not appear.

Why not?

Your file should be called views-view-field--presse.tpl.php. field without an 's' not views-view-fields--presse.tpl.php file


Two-way Entity Reference? I'm building a site for a school, with several content types:

A Class holds the general info about a class: description, tuition, etc. One field in the Class type is an Entity Reference for an Instructor.
An Instructor is the teacher of a Class.

When adding a new Class, the user will add an Instructor using the Entity Reference field (as an "autocomplete" widget). However, I also want the list of Instructors to link to the Classes each one teaches. How do I do this without having to enter the data on both the Class page and the Instructors page?

Actually found a great tutorial which explains in detail how to do this: Using Views Contextual Filter and Relationship to display reference on referenced node.

Now, I have another, related, question: What if I want to include the Classes taught by the Instructor on the "list of instructors" page (which is a View)?


Use Pathauto with Image Name With Drupal 7 I'm trying to use Pathauto to create aliases for images that we upload. The images are renamed with File Field Paths. An example of what I'm trying to do

What I'm trying to do

Image content type
Has an Image Field (CCK), field_image
Upload image with content type (example.jpg)
example.jpg is renamed to Ax54jk.jpg (File Field Paths)
mysite.com/node/523 is altered to mysite.com/Ax54jk (Pathauto)

I set a pattern for the Image content type of [node:field_image] which appears to yield httpmysitecomsitesdefaultfilesAx54jkjpg

So instead of creating http://mysite.com/Ax54jk, it creates http://mysite.com/httpmysitecomsitesdefaultfilesAx54jkjpg

While I was going for a unique URL, this is a bit more unique than I'd hope. Does anyone know how to accomplish what I'm looking to do?

The unfortunate answser is that Pathauto does its deed after File Field Paths. A custom solution will be needed.


Why does my Drush post_make hook not run from bash script? I have written a drush extension that runs some post_make operations.

It's all good when I run $ drush make normally.

I have also written a bash script, which with some arguments, perfoms also drush site-install and other file structure stuff. The problem is when I execute this script and bash runs my drush make, my extension and post_hook is not running.

I know it's more of a bash permissions/ownership thing or something, than a drush issue, but does anyone have an idea?

My extension lives in ~/.drush/extension.

I'm using drush 5.9 and this is the actual script.

Do you run the script as the same user that you run the drush make directly as?  Or do you perhaps run the script from cron?  Check to make sure that your $HOME environment variable is pointing to the expected directory; if $HOME is not set, then Drush will not find your commandfiles.


Running drush sql-sync between linux drupal alias as source and windows drupal alias as target throws rsync:chgrp error i can see from this post that rsync is trying to set group on the file which may not make sense for windows. The question is, how can i pass rsync options while running the sql-sync command as

drush sql-sync @linux_alias @windows_alias

I can run the same command between two linux drupal aliases without any problems.

Thanks!

Okay, i got it running. Followed instructions at this blog and i'm able to run it.

Specifically:

  The best way to solve this, is simply to add the following to your
  alias definition file for your local site:

  'target-command-specific' => array (  //commands used when this alias is the target
'sql-sync' => array (
  'create-db' => TRUE,  //create new database(merged databases can be trouble!)
  'mode' => 'rultvz',  // override sql-sync default $mode = '-akz' from rsync.core.inc
),

),


Rules- how to perform processing on cancelled accounts? I have my site configured to allow users to cancel their accounts, in which case the account is blocked and the content is unpublished.  I made a rule to act on the Event after a user account has been deleted, but my actions are not performed when a user cancels his/her account.

For this kind of configuration, you need to use the Event After updating a user account with the conditions User is blocked (account) and NOT User is blocked (account-unchanged).


What is the default behavior of the Drupal 7 cache? I can't find any specific documentation explaining how the default caching mechanism in Drupal 7 works and when does it clear caches automatically. From my own testing, I can state the following:

Cache is cleared when any content is added
Cache is cleared when any content is updated
Cache is NOT cleared when content is deleted!!! (Check my comment below for update).

Where can I find documentation to approve the above and also learn a little more about this topic? Any other cases where cache is auto cleared?

Details: the above results are based on turning on both "Cache pages for anonymous users" and "Cache blocks" and setting "Minimum cache lifetime" and "Expiration of cached pages" to none.

To find out all events when page and block cache is cleared - you can search through all modules for using of cache_clear_all() function.

Here is brief list of such events in Drupal core.

Any content is created or updated (nodes, taxonomy terms, comments, etc)
Content permissions are updated.
Block is created or updated.
Vocabulary created, edited or deleted.
Any settings form in admin back-end is submitted (those forms that use system_settings_form()).
User account is created, updated or canceled.

As you see page and block cache is not cleared automatically when any content is deleted.


How can I convert first page of a pdf as its thumbnail? I'm trying to build a document sharing site so I need to convert first page of each document as its thumbnail in a grid view. I've found some module like PDF-to-ImageField module, but unfortunately it has been released only for Drupal 6.

Now what can I do? is there any Module to convert first page of each document (specially pdf and doc) to a thumbnail for drupal 7? or any other ways?

Some people have started a Drupal 7 version, but it's nowhere near ready yet. If you can program for Drupal 7 and want to get involved, you could check out their Git repository and help them out.

If you're not ready to start porting D6 modules to D7, you could try one of these options to build those thumbnails, then write a little snippet of code to attach them to your nodes in your imagefields:

Stack Overflow: How do I convert a PDF document to a preview image in PHP?
Webvamp: How-to create PDF preview images in PHP


How to update custom paragaph which is added to User Profile? I have a requirement to create/update a paragraph which is added as a custom field in USER profile. After surfing here, i got how to update a paragraph which is connected to node. But I am not able figure out for User profile. Any help will be appreciated. I used below code for saving the paragraph, but how it will linked to $user->save(); ?

$paragraph = Paragraph::create([
      'type' => 'mmodule_paragraph',
      'field_employee_id' => 'Field value',
      'field_location' => 'Field value',
      'field_name' => 'Field value',
      'field_segment' => 'Field value',
    ]);
    $paragraph->save();

Don't save the paragraph, add it to the user field and then save it together with the user:

$paragraph = Paragraph::create([
  'type' => 'mmodule_paragraph',
  'field_employee_id' => 'Field value',
  'field_location' => 'Field value',
  'field_name' => 'Field value',
  'field_segment' => 'Field value',
]);
$user->field_paragraph[] = $paragraph;
$user->save();

In case you want to replace the field content overwrite the entire field array:

$user->field_paragraph = [['entity' => $paragraph]];


Uploaded pdf file with multiple dots (.) in name are renamed for security reason Authorized user gets an error each time when uploading a PDF with more than one dot in the name (other than the PDF extension, i.e this.is.an.example.10.pdf) but there are no disallowed extensions in the file name.

The error says "For security reasons, your upload has been renamed to..." (surprisingly the renamed file is the SAME as the original upload name!)
Since there are no exe php etc in the filename, why is this PDF being flagged? I searched for some time to no avail. Thanks!

when the upload file name contains multiple (.) in file name, after each dot it will be considered as extension of the file. In your case(this.is.an.example.10.pdf) it will check (is,an,examplem,10) in valid extension, It is not match with that it will add (_)inthat. If your uploaded file name is not same after drupal changes it will give that error. For more detail check file_munge_filename


How to add exist taxonomy term field to custom form It's possible to add exists taxonomy reference field to new custom form?

For example: i have a term field named "field_tags" and would like to add to new form ->

  $form['node_taxonomy_term'] = // load here exists taxonomy autocomplete field "field_tags"
  $form['#submit'][] = 'save_node_terms';
  return $form;

Not exactly i think, but you can implement next:

$form['node_taxonomy_term'] = array(
  '#type' => 'textfield',
  '#autocomplete_path' => 'ntt/autocomplete',
);

add menu callback for autocomplete path

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

  $items['ntt/autocomplete'] = array(
    'page callback' => 'node_taxonomy_term_autocomplete',
    'page arguments' => array(2),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

and add callback function

function node_taxonomy_term_autocomplete($str = 0) {
  $matches = array();
  //vocabulary id
  $vid = 2;

  $result = db_select('taxonomy_term_data', 't')
    -> fields('t', array('tid', 'name'))
    -> condition('vid', $vid, '=')
    -> condition('name', $str.'%%', 'LIKE')
    -> range(0, 10)
    -> execute();

  foreach ($result as $term) {
    $matches[$term -> tid] = check_plain($term -> name);
  }

  drupal_json_output($matches);
}

enjoy


Query nodes with a specific word in them I'm very new to Drupal and I need to grab all nodes that have a certain word in them, for example I want to grab all nodes with the Word 'Hello' inside the body field. I need to use the EntityFieldQuery class too. I'm assuming I need to use the fieldCondition method but not sure how to set that up as there's not a lot of documentation...

Thanks
Alex

I'm not sure I'd agree there's not a lot of documentation out there (there are tons, just search Google for EntityFieldQuery).

That said, something like:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'some_type')
  ->fieldCondition('body', 'value', '%' . db_like($input_string) . '%', 'LIKE');

$results = $query->execute();

is probably what you're looking for


Revision tab is not listing any revision I have the Node revision module (diff) installed, and I have many revisions for a node, but the Revision tab is not showing any of them, even though the database table contains the data for those revisions.

What may the reason be?

A core issue related to languages was just fixed today: NodeController::revisionOverview() shows no revisions if node has no translation for current language

However, since you use diff, which replaces that patch and does its own thing, it might be the same or a similar bug there. Create an issue, possibly reference to the core issue.


Allow comments on profile pages What are the ways to allow comments on user profile pages in Drupal 7? There is a profile content module, which unfortunately is not available for Drupal 7.

I think you can find an answer in this similar question here: How do I enable comments for user profiles?

Apparently, Profile2 module allows that functionnality.


Drupal 7 - View listing Organic Groups AND content within that group I'm trying to create a view that lists all of my Organic Groups on a page AND lists the content within that group. Specifically, I would like to show image fields that have been posted to each group.

Any ideas on how I can achieve this? I can't seem to get the relationships right.

Thank you in advance!

You can create a view that listas all content (filter by your choice), make sure you include the field Content: Audience group (og_group_ref).

Then you can go to Format > Format > Settings (style_options) and group by that field.


Add another node in create content Drupal 6 I am searching for a way to add content in node/add/page (for example) with a "Create another node (of this content type)" button. The button would add another form, and when the forms are submitted, Drupal would create 2 nodes.

Is there already a module that does this? How can I differently achieve this?

Try out Multi Node add module.

  This module provides a new interface for creating nodes where the
  users are able to select the fields what they want to use for creating
  the nodes.


How to set a Rules Condition "Does this node with date field use repeating functionality"? I want to set a condition based on whether a calendar item (node that uses a date field) has repeating values set.

I can't find anything relevant in the data selector. The rule event includes "content of type" so it's not an issue related to "entity has field." The relevant field is showing up in the data selector.

Also, in addition to wanting to determine "is this a repeating date", I'd want to get access to the repeat rule (by this "rule" I mean the rule created by the date module, not the Rules module). I see no data selector for that either.

I'm not aware of any Rules Condition to check for repeating attributes. However you may possibly get it to work by using a loop within your Rules Actions, to actually check how many repeating values you actually have.

To do so, have a look at the rule included in the answer to "How to add up all items of a field collection field using Rules?". You could use a similar set of Rules Actions (combined with whatever Rules Events/Conditions you want) to simply calculate how many values you have.

For that, all you need to do is to initialize some counter to zero (before the loop starts), and then add "1" to that counter for each list item. And after the Rules Loop is finished, you invoke a separate Rules Component to which you pass the counter (= result of your calculation) as a parameter. Within that Rules Component, you can add any Rules Conditions you'd want. And in its Rules Actions you perform the actual Rules Actions you want.

It might be worth to pass your date field also as an extra parameter to the Rules Component, so that possibly you can get access (whatever you mean by that) to that "repeat rule" also.

Note (about your comment): Using node:field-time:1:value might also work, but you'd first have to do some testing with that "data field is empty". I doubt a bit what happens in the case where you only have 1 value (= node:field-time:0:value), while you would be referring to node:field-time:1:value ... In that case it might cause some type of data exception or so (not sure though, to be verified). How about some data comparison related to node:field-time:1:value, or (more "safe") using a text comparison with an appropriate RegEx?


How to prevent the user profile page of a blocked user to show up? When a user is blocked the (core) user profile is still accessible. I would rather show a message "this user profile has been removed".

I could write an exception into the user-profile.tpl.php. Is there a better way?

You should be able to implement hook_user_view in a custom module.

First create a page which contains your preferred content (e.g. "This user profile has been removed").  Let's call this node/1337 for now.

Secondly, you want something along the lines of the following:

function mymodule_user_view($account, $view_mode, $langcode) {
  if ($account->status == '0') {
    drupal_goto('node/1337');
  }
}

There are other parameters you can pass to drupal_goto if you wish (such as HTTP response code) - check out the API for more info :-)


Content View to sort results to match the users Profile 2 taxonomy term I have a taxonomy term that gets assigned to a content type via entity reference, and the Drupal user, via Profile 2.

I want to add a filter to a content view that matches the 2 up, so if you filled in your user profile saying you only interested in x, have a view that only show content that was assigned with the same term.

I have tried adding author, profile2, taxonomy term relationships etc without any luck. Any pointers would be greatly appreciated.

I managed to solve this:
The key is to start with an User View.
Add Relationship -> User: Profile
Pick the profile where the taxonomy was assigned.
Add Relationship -> Content: Taxonomy terms on node
Pick your vocabulary.
Add Relationship -> User: Content authored
Add Contextual filter -> Content: Has taxonomy term ID
Choose PHP as a Provide default value option:

global $user;
$profiles = profile2_load_by_user($user);
    foreach ($profiles as $profile) {
      if ($items = field_get_items('profile2', $profile, 'field_your_interests')) {
        break;
      }
    }
$tids = array();
foreach ($items as $item) {
  $tids[] = $item['tid'];
}
return implode('+', $tids);

Then add the fields and additional filters as needed.

Resources:
http://blog.ampli.fi/filtering-a-drupal-7-view-based-on-multiple-user-profile-fields/
https://www.drupal.org/node/1111722#comment-4315620
Drupal terms and arrays - thanks Aaron!


How do I add a  class based on the visibility of a block? Is there a way to add a CSS class to the <body> tag based on the visibility of a  particular block on a page?

We have certain blocks that are visible on specific pages. It would be nice to be able to change CSS styles for related content depending on whether they are present.

How can I achieve this?

You have to do it via the template_preprocess_html function.

Add this to your theme's template.php file:

function MYTHEME_preprocess_html(&$variables) {
  // dpm($variables);
  $node = menu_get_object();
  if (isset($node) && isset($variables['page']['sidebar_first']['system_navigation'])) {
     $variables['classes_array'][] = 'system-navigation';
  }
}

In the above code I am looking for the system navigation block in the sidebar first region and if it is there I am adding system-navigation class to the classes array. I am also checking if I am on a node page via the call to menu_get_object()

You will have to adapt the code to your use case.

Install the devel module, then uncomment the dpm statement. Then look under the page variable at other variables without a # in front of them.


Organic Groups - Include nodes as part if it on group creation I'm looking for at way to make some nodes, eg. "About us", part of the Organic Group.

/
/about-us*
/more-general-stuff

When I create the OG I want the nodes marked with * to be part of the group.

/my-group
/my-group/about-us
/my-group/another-page-for-the-group

/my-group/about-us is a copy of /about-us, and if you edit /about-us it also updates /my-group/about-us.

/my-group/about-us could contain blocks specific for the group.

So when I tried to use views to create a page on /%/about-us, I'm not able to put blocks on that "page".

Any ideas is welcome.

You can use Rules to generate the nodes upon creation of the group.  If you haven't worked with Rules it is an incredibly powerful module and is well worth the time investment to learn its intricacies.


How to add in-place edit links? I need to put in-place links to edit nodes and blocks in Panels. I see that there are some modules in Drupal 6, like EazyEdit and Block edit, but I didn't find anything for Drupal 7 yet. So appreciate your hints, whether to pick up an existing project on how to do this.

There's an alpha version of Editable Fields for Drupal 7. The module:

  allows CCK fields to be edited on a node's display (e.g. at node/123), not just on the node edit pages (e.g. node/123/edit). It also works within views etc. Anywhere a 'formatter' can be selected, you can select editable (or click to edit).

It works for nodes, but not for blocks as far as I'm aware.

There's also the Aloha module:

  This module integrates the excellent HTML5 wysiwyg editor Aloha Editor (http://aloha-editor.org/) to Drupal. Both the module and the Aloha Editor library are under active development but still in the early stages.

But judging from the comments on the module page it might not be ready for use just yet. I did find an article with someone who claims to have got it working so that might be the place to start.


How to expose a select field to a Rules Condition? In Drupal 7, I have defined a new content type which has a checkbox field . The idea is that when a user chooses option A and submits the content, the system does something after the creation of the node, say, send an email to the webmaster and if the user choose option B or C while creating the content, the system do nothing.

I've had difficulty to expose the select field result to a Rules Condition and I'm even not sure whether it is possible, so appreciate your help.

Well, I found my answer:

I need to create a 'Entity has field' condition and equate it to the machine name of the field in question.

Then the field becomes exposed in 'Data Comparison' to be evaluated.


How do I display images from a field in a View as grid? I have a view that displays images from an image field of a specific node and I want to display those images in a grid but Views groups them together so the whole node is put into the grid cell instead of each image separately.

How can I make such View?

You can edit image field in view and uncheck "Display all values in the same row" checkbox under "MULTIPLE FIELD SETTINGS" fieldset. This will tell view to render each image in node as single row. See screenshot below for field settings:


Adding an existing file to the File records I have a unique situation where earlier in the day, a file is uploaded to the Drupal files directory for my site (through an outside service, such as SCP), and I need to index it inside the CMS so I can interface with it through the File API. What's the best approach to do this?

It may be easiest to create a special directory to receive these incoming files.
For example, if the directory is /var/www/sites/all/files/inbound then your code could do the following to scan the directory for new files and move them to the cms storage system:

  global $user;
  $new_files = (array) glob('/var/www/sites/all/files/inbound/*');
  foreach ($new_files as $filename) {
    $uri = file_unmanaged_move($filename);
    // Create a file object.
    $file = new stdClass();
    $file->fid = NULL;
    $file->uri = $uri;
    $file->filename = drupal_basename($uri);
    $file->filemime = file_get_mimetype($file->uri);
    $file->uid = $user->uid;
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
  }

If you want to run this periodically then you can add the above to an implementation of hook_cron.


Content type Images not displaying I have created views to display images. Clicking on the image takes to content. View displays the image but when clicking on image it takes to content where image is not displaying. Please help me.

This is almost certainly a permissions issue. You need to ensure the web user (apache?) has access to these files. I typically just

chmod -R www-data:www-data sites/default/files

and it does the job.


Spammers apply for an account, how to disable other users from applying for an account on my website I am using drupal 7 and get messages like these several times a day:

Account details for sizemutter at "my Website Name" (pending admin approval)

sizemutter has applied for an account.

I am afraid that I may approve one of these by mistake. Is there a way to make it for them impossible to apply and to stop spamming me?

Thank you!

There are several options. In addition to disallowing vistor registration (Navigate to Administration → Configuration → People → Account settings and select "Administrators only" under "Who can register accounts?", you may you one of several contributed modules that is designed to prevent spammer and spambots from registration.

My personal favourite is Mother May I.  It adds a field to the registration form where the registrant must type in a "secret word". If the registrant gets this wrong, no new account is created.  This is perfect for invitation only sites, where the invitation reveals the "secret word".  However, I find it works pretty well on other sites as well, where the "secret word" may be the answer to some a "riddle" that is solvable by humans but not by 'bots.

As an alternative to the above, there are are several contributed modules that let you add various types of CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) challenges to forms, including the user registration form. These block spam robots, but do not block human spam registrations. However, blocking 'bots take care of about 99 % of spam registratons, so doing this helps a lot.  The most popular module providing a CAPTCHA is named CAPTCHA. It comes with a built-in challenge, but is really a framework that to manage a set of CAPTCHA plugin modules, letting you experiment with these to find one CAPTCHA method that is effective for your site.

There are also contributed modules that provides a Drupal  interface to some external third party anti-spam service. The most effective of these is http:BL. an interface to the project Honeypot blacklist.  I've found that this module provides efficient blacklist lookups and blocks malicious visitors effectively.  (There a few false positives tho', in particular if your site attracts visitors that connects through TOR.)


How can I alter an "Add to cart" button at the submission time? I am using the Drupal Commerce module, and I need to fire some operation at the time the users click on the Add to cart button, but I am unable to find any hook for this.

I am using this code but it is not working.

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'commerce_cart_add_to_cart_form') {
    $form['#submit'][] = 'custom_submit';
  }
}

function custom_submit($form,$form_state) {
  die("Tesing");
  drupal_set_message(t("Don't panic!"), 'warning');
}

You can use the form alter as follows:

function hook_form_alter(&$form, &$form_state, $form_id) { //hook can be replaced by theme name if being defined in *template.php* of a theme and by the module name if function is being defined inside a custom module

  if($form_id == 'commerce_cart_add_to_cart_form') {

//HERE YOU CAN DEFINE A SUBMIT HANDLER, WHICH WILL ACT ON HITTING ADD TO CART BUTTON. Example:

    $form['#submit'][] = 'custom_submit';
  }

function custom_submit($form, &$form_state) { //custom submit handler

  //Add here the functionality you want to do on click of add to cart button

}


How to upload multiple images as multiple nodes? I built a social network website that is like Instagram (users can follow each other, upload images and ...) but it focuses on some event. People send us tens of thousands of images every year and we present them on their profile in the website.

Every thing is fine with this website. The only problem is for users who send many images (usually more than 50), It is difficult for them to click on Create New Content link for every image and save that image and create new content again. To solve this problem I allow the images content type to have unlimited number of image field and used Multipleupload Imagefield Widget to allow users to select multiple files at once.

But every content must have exactly one image, so if a user selects multiple images for a content, we need to have a mechanism to separate every image as a distinct content, we can also share the Title of the content among all of them.

The only solution I found so far is to build a module that check for the number of images and create new content for each one on node save hook. I would like to know is there any other solution? any module or strategy to handle this requirement?

Thanks.

UPDATE

as @Gokul N K recommended I installed Bulk File Nodes Module, I also installed Plupload module. After selecting the Image field in Bulk Photo Node Settings vertical tab, This is what I see in node/add/image

and I can't add any image, By clicking on next button this page is reloaded.

Check out Bulk File Nodes Module

  Bulk File Nodes allows a user to upload or import many files at once,
  and have many individual nodes created, one for each file . Where this
  module significantly differentiates from other modules like Bulk Media
  Upload is that after uploading/importing the file(s), the user is
  given the opportunity to edit all of the fields for each node in a
  single form.

  Another form to the right acts as a bulk settings form where each
  field that has a value is applied to each node's corresponding field,
  except where the user has overridden the bulk settings form by
  specifying a value in the field of an individual node.


Search index in drupal7 I tried following methods for search index in drupal 7:

Click on re-index site.
Number of items to index per cron run is 100.
Save Configration.
Run Cron and check the items count left to index.

I got "There are no new nodes. Cron run successfully." still I am getting (0% of the site has been indexed. There are 51996 items left to index) in index status.

if you have drush installed, you can do it this way:
 drush search-reindex --immediate --verbose

There is a dev module available that does the same thing.
https://drupal.org/project/reindex

It's probably a good idea to have the site in maintenance mode while you try this.


How do I configure the "input format" for the File Tree module? My question is in the input format step.  How do I "add File Tree to your input format?"

Here are the instructions from the File Tree module:
"Enable the module, and add File Tree to your input format. Then, enter [filetree dir="some-directory"] into the body field of a node, and it will render a list of all the files in that folder. (Note, the folder must reside in your site's "files" folder.)"

When I go to configure the module, I'm taken to
Home » Administration » Configuration » Content authoring » Text Formats

Filtered HTML - anonymous user, authenticated user, administrator
Full HTML - administrator
Plain text - All roles may use this format.

It says "Improper text format configuration is a security risk," so I want to make sure I have this right.  What is it that I need to add where to make File Tree work, safely and securely?

I found how to set the input format to use the input filter implemented by the File Tree module:

Go to text format configuration, accessible again by Home » Administration » Configuration » Content authoring » Text Formats (or by clicking on "Configure" for the File Tree module)
Click on Full HTML.
Halfway down, there should be several check boxes, among them one for "File Tree."  Just check that box and you're set.

Now, from here, I still haven't been able to get the module to run. Despite this change, I still see [filetree dir="dirname"] printed plainly where I try to insert a file tree.

(This video helped me: http://www.youtube.com/watch?v=ASKqit7kDak.)

If you want to get File Tree to work, after you set up the input filter, the directory you are referring in [filetree dir="dirname"] must be a directory contained in your site's "files" directory. If you want to display all the files in the "files" directory use [filetree dir="/"], or if you want to display a particular directory, put the files in a directory (say, dir1) under files and specify [filetree dir="/dir1"].


Database 4 byte UTF-8 support not properly checking In the status report of my drupal website I got the message that I had to up Database 4 byte UTF-8 support. I updated all my tables and database like it's told here: https://www.drupal.org/node/2754539. I checked and all my tables and the database have utf8mb4 encoding and utf8mb4_general_ci collation.

I get the following warning:

  Enabled, but database tables need conversion Please convert all
  database tables to utf8mb4 prior to enabling it in settings.php. See
  the documentation on adding 4 byte UTF-8 support for more information.

I fixed it by manual setting the drupal_all_databases_are_utf8mb4 variable to true. You can do this by using drush or setting it in the database and then clear all caches.


How can i include views page in search results I had created a view called "donor" with a page display. I includes nodes from content type "Donor-node". The title of "donor" views page is "donor wall". I created a view with type as content, which lists all nodes. An exposed search form with search term field. Is there any way to include "donor wall" page in this search results. If any one search for a key word donor, donor wall needs to list in result.

Building a page via the views interface implements this page with the hook_menu. An entirely different approach from the nodes wich are saved in the database.

Views is essentially a query engine wich basically searches those database tables (and only one base table per view).

There is no real way to make a hook_menu implementation appear a node view.
Ollies advice to put your view into a block and add it to a node is probably the best viable option.


how to add custom additional password suggetions descriptions points in drupal 7? I want to add few more suggestions points to existing password suggestions description in drupal 7 while registering new user. So tell me is it possible to modify it ?

Add this to your front-end theme's template.php file:

function THEME_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case 'user_register_form':
    case 'user_profile_form':
      $form['account']['mail']['#description'] .= "And some additional stuff.";
          break;
  }
}

Add similar to admin theme if need be.

Clear the cache when you are done.

Alternatively try Better field descriptions.

  Better field descriptions makes it possible to add themeable
  descriptions to fields in forms.

I have never tried it but it looks like it could do the job, through just adding your own form_alter hook is much simpler.


how to use if exists inside db_query I try to create a condition that checks if user has already created a node.

I use this code which returns the last created node by the user. Adding simple if statement I can return true/false.

$xxx = db_query("SELECT nid FROM {node} WHERE (type = :type1) AND (uid = '123')", array("type1" => 'nodetype_x'))->fetchField();
return $xxx;

I tried to do it more efficient to check only for first result like this.

$xxx = db_query("
IF EXISTS(
      SELECT nid FROM {node} WHERE (type = :type1) AND (uid = '123')
)
SELECT 1
ELSE
SELECT 0", array("type1" => 'nodetype_x'))->fetchField();

But get syntax error. What would be the correct syntax? Thank you

This is really not the ideal way to do this. Instead you may want to try something like:

$query = db_select('node', 'n')
  ->condition('n.type', $type)
  ->condition('n.uid', $uid)
  ->fields('n', array('nid'));

$count = $query->countQuery()->execute()->fetchField();

if ($count) {
  return true;
}

return false;


Add a block in page content that use viewreference I have a content type that use viewreference module to display views on page content.

So every field added with the type "View reference" in manage field section will display the corresponding view.

I want to insert a new created custom block, between those views(witch are fields in reality).

to be more clear:

  Field 1 => displays view 1
  Field 2 => displays view 2
  I want my block here
  Field 3 => displays view 3

Thanks in advance.

The Block reference module may be what you are looking for.


Include Vimeo's Froogaloop library I have a custom module that has a JavaScript file in it. The JavaScript file is calling on the Vimeo API, which has a custom library created for it (similar to jQuery).

How can I use this library in the custom module's .js file? I've tried putting Froogaloop (the Vimeo library) inside of sites/all/libraries and then using its syntax it in the .js file within the custom module, but it's not picking the library up.

Is your js file even working?

Is your JavaScript file jQuery?

In Drupal, you wrap your jQuery code like this

(function ($) {

    //code goes here

})(jQuery);

For Example:

(function ($) {

    $(document).ready(function() {
         $(".button").click(function () {
             $(this).next('.content').hide();
         });
    });

})(jQuery);

Not sure if you did this already.

Did you also add the frugaloop js to your module? Putting it on the libraries folder doesn't do anything unless you call it.

Use the function drupal_add_js to call it.


Pass the id of one node by url for new node I have 2 content types, person and date. Date have a relation with person, in one node of person, you can see the dates of that person.

I want add a link in the nodes of person for add a date for that person (this is easy), i need pass the id of the person node automatically to the new node of date.

I don't know how to do this, anyone can help me?

Thanks.

EDIT:

Will try to explain it better:

I use node reference module for create the relation between the two content types. When i add a node of date, all fields are in blanc, if i add one date node through node of person, the id of that node, will add automatically to the new date node in the field that relation the two content types.

One easy way to do this is with the module

nodereference_url

  The Node Reference URL Widget module adds a new widget to the Node
  Reference field type. It auto-populates a node reference field with a
  value from the URL, and does not allow this value to be changed once
  set. It can automatically provide a link on the referencing node
  types, that will contain the proper URL to prepopulate the field.


In drupal 7, How to override theme_pager? I am using drupal 7 and zen theme. And am not able to override the theme_pager using zen_pager function in template.php. Any suggestion pls?

Implement all/selected of the following theme functions in your template.php:

theme_pager() - main theming function, using:

theme_pager_first()
theme_pager_previous()
theme_pager_next()
theme_pager_last()

changing 'theme' in each of these function names to short name of your theme.


pagination broken on custom theme's search system page I do not have pagination on the system search page .../search*.

When I toggle off my custom theme I have pagination on the search-result.tpl.php page, I can see the $pager variable. But on my custom theme I cannot find that variable, it doesn't show up. I have checked hook_query_alter() throughout all of my site and I do not see any conflict. I checked the template.php file and there is no issue there. I will begin to remove everything, piece by piece to find out if I can find a solution.

No real code to show, and I would send you a stock search-results.tpl.php page, but the code block doesn't want to show it because <?php ?> is interspersed with html tags. It is something like:

if ($search_results) {  print t('search results');   print $pager; }

I simplified it because of the aformentioned issue, but this is essentially it - it is so minimal it is laughable and it works for any other theme, but mine. So I just copy the search-results.tpl.php file over to bartik, then do drush cc -v all and recheck and I can use xdebugger to see the $pager variable, but the same file with my custom theme I never get the $pager variable.

So i found out that a view on the search page had pagination and it caused a conflict with the search results pagination! I removed pagination in the View's configuration screen.

Removed the pagination of the pager settings.


Import a date from CSV to Date field I'm working on a Druapl 8 project and I'm trying to execute a migration which serve to import content of a basic content type, the content type has a field of type Date and the associated field in my CSV source file has the format "dd-mm-yyyy", I used the 'format_date' plugin to migrate the date as bellow:

process:
  field_date:
    plugin: format_date
    from_format: 'd-m-Y'
    to_format: 'd/m/Y'
    source: Date

with field_date is the machine name of my content type date field, and Date is the field name in my csv file:
source.csv

title,Date
title 1,12-01-2017
title 2,13-03-2018

After migration the content has been created as it should but with date value as bellow:

Any help please!

You need to convert source date from d-m-Y to Y-m-d

process:
  field_date:
    plugin: format_date
    from_format: 'd-m-Y'
    to_format: 'Y-m-d'
    source: Date

because default field Date use format Y-m-d to store date. and Y-m-d\TH:i:s to store datatime.

Form display just show default pattern (mm-dd-yyyy) of html5 input date


Is it possible to restrict access to anonymous user to specific content types based on the author? I've been looking for a module that could support my requirement for hours now and failed.

What I want to do is to restrict anonymous user to viewing content type pages based on a specific users. Lets say I have user1,user2 and user3. Anon should be able to view contents created by user1, but not user2 and user3.

I'm thinking of using node_access_hooks but I'm very new to drupal and I have no idea where to start with that. Can anyone help me with this?

I don't think it looks like the best idea - sometimes you have to fire an author and get someone new. Author-based solutions may get complicated in such situations. Usually I use Taxonomy Access Control - I'm restricting users to view only content with particular term, and only give access to that term to particular authors. Simple, and without need of any custom coding.

Note one important restriction:

  While Drupal 7 makes support for additional databases possible, TAC does not currently support databases other than MySQL/MariaDB/etc. or Postgres. See #1266674: Support other databases for more information.


Comment theming question In Drupal 7, when theming the comments in my website (comment.tpl.php), I want to print the comment title without a permalink wrapped around as a link. I want the raw title. This should be simple, it seems, but it seems there is no variable for that. print $title will show the title wrapped with the permalink link.

Do I have to mess with template.php to fix that?

I also tried render($content['subject']), but nothing it is printed on the screen.

According to the documentation of comment.tpl.php, you should have access to $comment, so the following should work:

<?php print $comment->subject; ?>


How to load file, when I know it's filename, but not fid? I create filenames using some ID and timestamps. I don't want to add additional table to "remember" associations, as filename keeps them pretty well:

$filename = get_symbol_by_id($id) . ' ' . get_modified_by_id($id) . '.xml';

Also, I don't care if they will be managed or not. And I don't care if they get deleted - I can recreate them on demand. They are small, so leaving older ones behind does not create any cost worth taking care of. What is the proper course of action?

"Unmanaged" files seems to be generally discouraged in 7, but using them is pretty straightforward with tools like:

file_unmanaged_save_data
file_exists($uri) in a manner shown here
file_transfer takes $uri, not $fid, so it's even easier to use it on unmanaged files

With managed files, I'm afraid I would be forced to use

EntityFieldQuery, overly complicated for such simple task or
$conditions in file_load_multiple, marked as deprecated.

So what's the proper course of action, if I want to avoid both deprecated functionality and overly complicated code?

I'd definitely go with EntityFieldQuery, not a really complicated solution:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'file')
      ->propertyCondition('filename', '<filename>%', 'LIKE');
$result = $query->execute();
if (!empty($result['file'])) {
  $files = entity_load('file', array_keys($result['file']));
}

Use of conditions is not really recommended on any load multiple function anymore, the method above would be more standard and "future proof" as EntityQuery is the way to go in Drupal 8.

Installing file entity module would add much more value on what you can do regarding managed files.


Recoverable fatal error on nodes after leaving Maintenance mode Our site was in maintenance mode for several days, and when we came out of maintenance mode a bunch (we don't know how many) of our nodes display this error:

  Recoverable fatal error: Object of class stdClass could not be converted to string in DatabaseStatementBase->execute() (line 2136 of includes/database/database.inc).

This error can be found on this page -> http://www.relevantmagazine.com/node/109771
we are able to edit and save the node, but nothing we change fixes the issue.

Any ideas?

You probably included an object as an argument to one of your query conditions. If you print_r the $args at the line number in the database.inc file, you find out what the placeholders are set to.


Insecure fmath editor fmath is an extremely powerful plug-in library for wysiwyg editors.

It provides an editor for mathematical formulas, which generates images that can be used in drupal sites. It processes mathml and latex.

There is a problem though, images are saved on a server using the following php file.

if($_POST["save"]){
   $type = $_POST["type"];
   if($_POST["name"] and ($type=="JPG" or $type=="PNG")){
      $img = base64_decode($_POST["image"]);
      $myFile = "img/".$_POST["name"].".".$type ;
      $fh = fopen($myFile, 'w');
      fwrite($fh, $img);
      fclose($fh);
      echo "http://your_server/capture/img/".$_POST["name"].".".$type;
   }
}else{
   header('Content-Type: image/jpeg');
   echo base64_decode($_POST["image"]);
}

This file is publicly available, and can not be restricted with .htaccess to localhost only (the whole library will not work).

From my understanding the file is called by scripts on a user side via an url, and the image is passed by the POST method. That makes the file very dangerous as it allows anyone to save anything on the server.

Are my suspicions correct?
How can I make this safe to use?

The whole library weights 11MB so I don't feel like debugging it.

This should really be addressed to the fmath project maintainers. I've mailed them to point out some security concerns in the code. If they don't respond I'll edit this post to answer the question here, but hopefully they will respond with a new version ;)

Original comment - mailed to fmath maintainer:

Some key things this is missing that you would want to get right:

CSRF protection - If you don't use the form API (which includes this already) then you can manually use drupal_get_token and drupal_valid_token are helpers.
Malicious file types - file_munge_filename is a helper here
Too many/too big of files
Temporarily uploading the file to a temporary directory outside of the webroot and giving it a random name so that it can be validated in that temporary location before moving it to the final location
Ideally you would validate the file contents (e.g. virus scan, confirm the file is a valid file of whatever the extension/mime type says it is).
Control where the file can be placed.

This script looks like it would only allow jpg or png files to be uploaded, but it misses out on a few other security features

There are probably a few other things to worry about, but I think that list is a good start.

I also wonder about this piece and whether you could sneak base64 encoded html into a "jpg" file and then some veresions of internet explorer and safari will do mime type detection and execute the html (i.e. cross site scripting attack):

   echo base64_decode($_POST["image"]);


Why is my unit test not detected? I have a custom Drupal 8 module for which I'm trying to create unit tests by following the instructions at https://www.drupal.org/phpunit.

The path of my module is: /modules/custom/dev_module
The path of my tests is: /modules/custom/dev_module/tests/src/Unit

More specifically, in the Unit folder I have a DummyTest.php file with the following code:

<?php

namespace Drupal\dev_module\Tests;

use Drupal\Tests\UnitTestCase;

/**
 * My dummy test.
 *
 * @group dummy_test
 */
class DummyTest extends UnitTestCase {

  public function testDummy() {
    $this->assertEquals(5, 5);
  }

}

When executing the following commands from the terminal (I'm on Mac OS):

 > cd core
 > ../vendor/bin/phpunit --list-groups

My group dummy_test doesn't show up in the listed groups. Any idea why?

Unit tests must have the following namespace: Drupal\Tests\dev_module\Unit.

For complicated reasons, they also don't show up in the right group but they are all in the PHPUnit group.

To run your unit tests with phpunit, just pass the module folder, that also makes it 10x faster for finding the tests:

./vendor/bin/phpunit -c core modules/dev_module


How to Display a Single Image Gallery per Album in Content Teaser? I have made a Hierarchical Photography site using Views, Panels and Organic Groups.

The Hierarchy is as follows:

Top-Level: Category (e.g. - SCENIC, STREET SCENES, MODELS )
Sub-Level1: ALBUMS | (e.g."BROOKLYN" and "Mid-Manhattan | July 2016" under STREET SCENES Category)
Sub-Level2: IMAGE GALLERY (e.g. "Commercial and Residential" and "Midtown Streets" under MANHATTAN Album)

Using Views, I am able to display a preview using a single image from the Gallery, of each Image Gallery under its respective Album.  See attached "album view" screenshot..

One the Category Level, I am trying to create a preview image of each Album using a single image from one of the image galleries in each Album to represent that Album on the Category page, but instead it displays all the image galleries from each album.  See attached 'category view" screenshot....

In both views, I am using Panels on the pages to help structure them.

Here is my View for the Category Level:

and my ALBUM TEASER VIEW

and finally my Image Gallery View....

Any ideas on how to ensure only one Image Gallery per Album appears on the Category Level when using Content:Teaser?  Thank You!

Okay Drupalizer!  You don't need any special coding or modules to fix this.  I figured it out.  So basically, I just needed to create a NEW view of the Album Image Gallery Teaser with the same settings except for the Pager which I made to be "Display a specified number of items | 1 item".

Then I use this view as the Content Teaser for the Category Level and the Content-type 'ALBUM" I set the teaser display to be this EVA view.

See attached screenshot ...


Creating commerce product display in rules with PHP results in error This problem is to do with the following modules:

Drupal Commerce
Rules
Entity

I have the following code in an "Execute custom PHP code" Rules action. It creates a product display to go with a product (also created by Rules).

The problem is, it does not populate the product reference field (field_product_reference) and gives an error.

Code:

$product = $contact_details_product;
$display = new stdClass();
$display->type = 'product_display_regular';
node_object_prepare($display);

$display->title  = "Product display";
$display->language = LANGUAGE_NONE;

$display->field_product_reference['und'][0]['product_id'] = $product->product_id;
echo "TYPE: " . gettype($product->product_id);
node_save($display);

Where:

$contact_details_product is a variable available in Rules due to the previously created 'product' (as opposed to the display). This product was created in the same rule by a previous action.
product_display_regular is the product display content type.
field_product_reference is the machine name of the product reference field.

Error:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/test/public_html/includes/entity.inc).

Hacking entity.inc to display some values showed that at some point the variable on line 178 gets a null value, so I'm guessing there's a problem with the php code in the rule.
Output of gettype and print_r in entity.inc:

TYPE: string
Array ( [0] => 170 )
TYPE: string
Array ( [0] => 170 )
TYPE: NULL
Array ( [0] => )
...

That's about all I have right now. Can give more info if needed.
Cheers!

On further investigation it seems that the product created by Rules (in the previous action) is not assigning a product_id in the first place. Therefore there is nothing to assign to the 'product display'.

(I still don't understand why this is happening but rather than change this question completely I will post a new question.)


Query a list of field values of a node in drupal 7 I am new to drupal 7, I have a question and hope to receive your helpful responses! :D

I've created a new content type named 'school', and create a custom 'city' field in it.
After that, I create two new nodes of 'school', and their city are 'London' and 'Beijing'.
How can I get a list of city of schools programmatically in Drupal 7?

Any help will be appreciated!

Consider using the Forena module, it comes with all sorts of reporting features. And all sorts of hooks if you want to use them in your own custom modules.
Here is an excerpt from its Community documentation:

Forena Reports is built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.
It is designed to leverage existing knowledge of HTML, CSS, SQL and JavaScript to help you create rich interactive web reports.

Disclosure: I'm a co-maintainer of Forena,
I hope this does not violate the site's policy on self-promotion.


What is the best way to delete or disable ( most expected) the field of a content type? We have several content types (features) on our Backend, now site Administrators (authors) and content managers need some field to be disabled when creating content. How I can manage it?
I heart about the 'field_permission' module but I'm not sure if that module can solve my problem.
What could be the best way to disable these fields? Is there some module or could some one explain where I should start?
Pseudo code are Welcome
Thank you in advance
Hermann

Here's what I usually do.

Find contents that have data for those fields you want to delete.(You can easily find it in DB)
Delete all contents found in step 1 or remove data from those contents.
Remove the field from content type.


How to ignore the first argument in view contextual filters? I am having path aliases of the form

path/val1/val2/data

that are created with pathauto. I want to create a view that will be use a contextual filter and that will read only section 3 of the URL. When I set the view path to:

path/%/%/data

then I need to specify a contextual filter for section 3 (val2) that cannot filter my data properly.

My configuration looks like:

Filter configuration:

So I need the CELEX content filter to match section 3 of the URL. Can I entirely skip %2 and just filter based on %3? Alternatively, can I declare the second section to be a wildcard in the view path?

When I attempt to Provide default value as Bryan Jones suggested, then it seems that default value doesn't work because the context filter actually DOES match the URL section, whereas the default value is provided when the filter value is NOT in the URL

What I see after previewing the view is

Context values:

Query:
(Notice the value that I wanted to be val2)

There is a specific contextual filter called "Global: Null" that you can employ to ignore a path part and leave the query unchanged. You will have to reorder the filters so that Null is in the right position (in your case, the first, since you want to ignore the first % of the path). See the screenshot: