How to replace the Bartik default menu with Superfish Since the default Bartik menu doesn't allow me to create a sub menu with styles, I created a Superfish menu.
How can I replace the Bartik default menu with Superfish on the exact place?

I found a report, How to apply Bartik main-menu styles to other menu modules similar to Superfish. Essentially, the trick is not to apply the CSS styles used by Superfish to the CSS styles used by the theme, but to include the CSS styles used by the theme in the CSS styles used by Superfish.

The steps reported in that post are the following (I am editing them to change the format).

Create a new style sheet (NewStyleSheet.css) and save it to your file directory.
Edit the block settings for Superfish in /admin/structure/block. This step list assumes you are using a template that includes a "Menu Bar" or similar block area.

Move the block "Superfish X" to the "Menu Bar" region, by changing the drop down selector value to "Menu Bar."
Click "Configure" under "Operations," on the far right of the setting page.
Under "Superfish Settings," change "Menu Type" to "NavBar."
Optionally, select "NO" on both "Drop shadows" and "Auto-arrows", as this would take more time to modify the CSS to get them to show up properly.
In "Advanced Settings," add your new stylesheet location to "Extra CSS."

This is the content of the new CSS file.

/* $Id: whiteTab.css,v 1.0 2011/02/18 05:45:00 erok415 Exp $ */

/*-------------------------------------------------------------*/
/*                                                             */
/*      Important - Be sure to change all references           */
/*      from #superfish-3 below to match the number of the     */
/*      Superfish "X" block region you are using in your       */
/*      Block Settings. I used block region Superfish 3,       */
/*      hence I am using #superfish-3 below.                   */
/*                                                             */
/*-------------------------------------------------------------*/

/*-------------------------------------------------------------*/
/*                                                             */
/*   I have not attempted to use style the 4th level flyout,   */
/*      Auto-arros or the drop shadow features.                   */
/*                                                             */
/*-------------------------------------------------------------*/

#menu-bar{
  margin-bottom:10px;/* Add padding so secondary navigation doesn't run over search sidebar. */
}

sfHover, ul#superfish-3 > li:hover{
  background: none repeat scroll 0% 0% transparent; /* Remove the default background on top level tabs in default state and hover state. */
}

ul#superfish-3 li.sfHover li  a:hover, ul#superfish-3  li.sfHover  li a.active{ /*Secondary Nav: add effect to hover or active state here. */
  color:#09F;
  width:100%;
}

ul#superfish-3 > li > a{ /* Fist level horizontal navigation. */
  margin:4px 2px 0 0; /* Spacing around tabs. */
  color: #333;
  background: #fff;
  background: rgba(255, 255, 255, 1.0);
  float: left; /* LTR */
  padding:0px 6px 6px 6px;
  /* height: 1.8em;
  line-height: 2.4em;
  padding: 0 0.8em; */
  text-decoration: none;
  /* text-shadow: 0 0.5px #999; */
  font-weight:bold;
  -khtml-border-radius-topleft: 8px;
  -khtml-border-radius-topright: 8px;
  -moz-border-radius-topleft: 8px;
  -moz-border-radius-topright: 8px;
  -webkit-border-top-left-radius: 8px;
  -webkit-border-top-right-radius: 8px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

ul#superfish-3 > li.sfHover {
  background: none repeat scroll 0% 0% transparent; /* Remove the default background from the sfHover state. */
}

ul#superfish-3 > li.sfHover > a { /* First level hover and active state. */
  margin:4px 2px 0 0; /* Spacing around tabs. */
  color: #333;
  background: #999;
  background: rgba(153, 153, 153, 1.0);
float: left; /* LTR */
  padding:0px 6px 6px 6px;
  /* height: 1.8em;
  line-height: 2.4em;
  padding: 0 0.8em; */
  text-decoration: none;
  /* text-shadow: 0 0.5px #999; */
  font-weight:bold;
  -khtml-border-radius-topleft: 8px;
  -khtml-border-radius-topright: 8px;
  -moz-border-radius-topleft: 8px;
  -moz-border-radius-topright: 8px;
  -webkit-border-top-left-radius: 8px;
  -webkit-border-top-right-radius: 8px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/*------------------- Secondary Nav -------------------*/
.sf-navbar > li > ul{ /* Add background color to secondary nab only. */
  background:none repeat scroll 0% 0% rgb(51, 51, 51);
  background: #333;
}

ul#superfish-3 > li > ul{
  left:-15px; /* Align the menu with the left edge of design. */
  border-right:30px solid #333;/* Add the background color to the right edge because the style attribute above leaves a blank spot due to global conditions. */
}

ul#superfish-3 > li > ul > li {
  left:15px;/*Fix: aligns secondary level nav text with top level nav*/
  border:0;
}

ul#superfish-3 > li.sfHover > ul > li > a{ /* Secondary Nav: Remove tab effect from sfHover state applied to lower level nav. */
  color:#fff;
  background: #333;
  -khtml-border-radius: 0px;
  -moz-border-radius: 0px;
  -webkit-border-top: 0px;
  border-radius: 0px;
  width:100%;
  height:2.0em;
  line-height:1.1em;
  padding:6px 0 0 6px;
  margin:0 16px 0 0;
}

ul#superfish-3 > li > ul > li > a{ /* Secondary horizontal navigation. */
  color:#fff;
  font-weight:bold;
  /* text-shadow: 0 0.5px #CCC; */
  background: none repeat scroll 0% 0% transparent;
  -khtml-border-radius:0;
  -moz-border-radius:0;
  -webkit-border-radius:0;
  padding:0;
}

/*--------------- Third level DropDown navigation ------------*/
ul#superfish-3 > li > ul > li > ul {
  -khtml-border-radius: 0px;
  -moz-border-radius: 0px;
  -webkit-border-top: 0px;
  border-radius: 0px;
  margin:0;
  padding:0 0 0 6px;
  border:0;
  left:-0px;
  background: none repeat scroll 0% 0% transparent;
}

ul#superfish-3 > li > ul > li > ul > li  {
  margin:0px;
  border-right:0;
  left:0;
  border:0;
  padding:6px 6px 0px 6px;
  background:#333;
}

ul#superfish-3 > li > ul > li > ul > li:hover{
}

ul#superfish-3 > li > ul > li > ul > li > a {
  background:#333;
  margin:0;
  padding:0 6px 0px 6px;
  line-height:1.3em;
  background:#333;
}

ul#superfish-3 > li > ul > li > ul > li > a:hover {
  background: none repeat scroll 0% 0% transparent !important;
}


hook_update_N is not running I know there is a question hook_update_N not running but I checked its answers and it didn't help. I'm just learning developing modules for Drupal so maybe it's something really stupid but I have no idea...

My hook (in testModule4.install):

function testModule4_update_7001() {

$schema['testModule4_table'] = array(
    'description' => 'TODO: Description',
    'fields' => array(
        'main_id' => array(
            'description' => 'TODO: Description.',
            'type' => 'serial',
            'not null' => TRUE,
        ),
        'settings' => array(
            'description' => 'TODO: Description',
            'type' => 'text',
            'not null' => FALSE,
        ),
        'uid' => array(
            'description' => 'TODO: Description',
            'type' => 'int',
            'not null' => FALSE,
        ),
        'created' => array(
            'description' => 'TODO: Description',
            'type' => 'int',
            'not null' => FALSE,
        ),
        'changed' => array(
            'description' => 'TODO: Description',
            'type' => 'int',
            'not null' => FALSE,
        ),
    ),
    'primary key' => array('main_id'),
);

db_create_table('testModule4_table', $schema['testModule4_table']);

}

My module is working just fine. The schema_version of module in database is 0 but update.php just cannot see it. What can be the cause of that? :/ I was trying clearing cache and reenabling a module but without success. I just don't know where to search for source of the problem. If you need more data, just comment :/ .

Edit:

I created simple module:

testModule.module:

<?php

function testModule_myform($delta = "") {

    $form['something'] = array(
        '#type' => 'markup',
        '#markup' => 'Something',
    );
    return $form;
}

/**
 * Implements hook_menu();
 */

function testModule_menu() {
    $items["test/test"] = array(
        'title' => 'testModule',
        'description' => 'TODO: Description',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('testModule_myform'),
        'access callback' => TRUE,

    );
    return $items;
}

testModule.info:

name = testModule
description = Test module for Drupal experiments.
package = CustomTest
core = 7.x

testModule.install:

function testModule_update_7001() {
    drupal_set_message('It works!');
    print 'Show something!';
}

And it still ignores this hook... Is it officially a Drupal bug and I need to reinstall the whole Drupal? >_<

The problem is upper/lowercase in your module name.

To be able to run update functions, your module must consist of lowercase characters only. Unlike all other hooks, those are detected through regexes and the way it's implemented isn't compatible with mixed case.


Views php field or filter to a file or module If I already have a view with a php filter or a php field, in drupal 7, how can I convert my whole view into a page? (prevent code injections or other security risks)
What is the right way to resolve this?
Writing a module or a tpl.php file?
Thanks

Found the answer here

Custom Views Field Handler
https://kalamuna.atlassian.net/wiki/display/KALA/Custom+Views+Field+Handler


Changing cck form field options i'd like to dynamically change the option labels of a cck form field in the edit node form.

i allready found ou, that i can't do this in hook_form_alter, since the cck fields aren't in the form object at this time. so i added a after_build function. in this function, i'm trying to set the option labels like this:

function _mymodule_after_build($form, &$form_state) {
   $form['field_product_alternativtitle']['value']['#options'][1] = "foo";
   $form['field_product_alternativtitle']['value']['#options'][2] = "bar";
   $form['field_product_alternativtitle']['value']['#options'][3] = "meh";
   return $form;
}

This, however doesn't change the output of the form in any way.
I guess this is logical, since my function gets calles AFTER the BUILD of the form.

so my question is, how can i achieve my goal?

I would check a couple of things.

For sanity, make sure that your after_build function is being called by adding a drupal_set_message().
The labels will only change in the Edit form if your values are literally '1', '2' and '3'. Once you save the form, however, drupal will save the original value, not your new label.

function mymodule_after_build($form, &$form_state) {
  $form['field_some_options']['value']['#options'][1] = 'hiyo';
  return $form;
}


Theme the taxonomy tags list in the node teaser In my Drupal site I have node teasers that show taxonomy terms. As it stands they are like:

Tags:

Houses

Tags:

        Houses

I cant locate where the  anchor tag is being generated. I want to be able to change it to a <button> tag instead of anchor.

Any ideas how to do this?

Take a look at this tutorial that shows you how to create a custom formatter for specific field types. The taxonomy term field type machine name is taxonomy_term_reference


How can I access an external table in a MySQL database? I have a database (MySQL) with information about food.

It has several columns, for example:

-----------------------------------------
| product name | calories | fat | unit  |
-----------------------------------------
| bread        | 100      | 10  | grams |
| potatoes     |  50      | 20  | grams |
-----------------------------------------

Is there anyway way to import this dataset into Drupal and work with it in a field type, perhaps with taxonomy? Or should I program my own module?

Here is a module that will help you: http://drupal.org/project/data

[ edit re MPD suggestion below ...]

This module will help by providing an automatic Views integration for your data, meaning that you can show the data via Views.

It also includes an API which simplifies custom programming to get access to your data (perhaps for use in preprocess functions, which would permit the data to be themed on a node page, etc.)

Regarding your desire to include taxonomy, one way to do that would be to fold the data onto a node and then attach taxonomy to that node, however, that might depend on how you're mapping your data onto individual nodes.


Modification of email template I am working on a site where I changed the "email template" email to be sent on registration request to the user. How can I change the "email template" email sent to the site administrators?

I am using Drupal 7.

Go to admin/config/people/accounts, Under Emails click Account Activation and then change as per your requirement. Use html and css for customization. See the below image

(or)

Use the second option below:

All the emails are being sent from the system and the content is editable as we want. To stylize the emails, use html mail module http://drupal.org/project/htmlmail

This module allows you to theme emails leaving the system as you would theme a normal Drupal site, and replaces the outgoing emails with those HTML versions per your settings.

hope it helps you!!!


Drupal 7 Commerce: How to change cart page title? Have changed everything else for the cart in the settings file but the page title doesnt work. Page title is 'Shopping cart' so would expect it to be basket as its set below however this is changing the title of 'basket' link (which is good) but not the page title. Suggestions please?

$conf['locale_custom_strings_en'][''] = array(
  'Shopping cart' => 'Basket',
  'Shopping cart (@count items)' => 'Basket (@count items)',
  'Shopping cart (1 item)' => 'Basket (@count item)',
  'Your shopping cart has been updated.' => 'Your shopping basket has been updated.',
  'Your shopping cart is empty.' => 'Your shopping basket is empty.',
  '%title removed from your cart.' => '%title removed from your shopping basket.',
  '%title could not be added to your cart.' => '%title could not be added to your shopping basket.',
  'Add to cart' => 'Add to Basket',
  'Update cart' => 'Update Basket',
  'View cart' => 'View basket',
  'Shopping cart contents' => 'Shopping basket contents'
);

There are probably a dozen different places you could do this, personally I'd go for hook_page_alter() in a custom module:

function MYMODULE_page_alter(&$page) {
  // Make sure you're on the right page
  if ($_GET['q'] == 'cart') {
    drupal_set_title('New title');
  }
}

You would probably get away with doing the same thing in your theme's template.php file (maybe in hook_preprocess_page()) if you're not keen on writing a custom module just for this functionality.

The alternative to this is to install the String Overrides module. I've used this module in the past to override the title for exactly the same page (/cart) and it works great. It also means you can take your translation strings out of the settings.php file, which in my opinion isn't necessarily the best place to have them (even though it's absolutely a 'Drupal' way to solve the problem).


How to get field collection value in tpl file in drupal 7? I have created a content type and take field collection for some field. Within field collection I have taken 4 select box. Now I need to get these select box value in content type tpl file. For this I am using this code : $wrapper = entity_metadata_wrapper('node', $node_data);

but its not giving me select box option value.

Use entity_load('field_collection_item', array($item_id)) or field_collection_field_get_entity($item)

Sample

$node = node_load($id);
$items = field_get_items('node', $node, 'field_fc');
foreach ($items as $item) {
$fc_value = field_collection_field_get_entity($item);
// Do something.
}

For reference link 1, link 2


How to add html tags in drupal 7 menu? I would like to add
 tag or &nbsp; character to html menu, but when I type Home
 Page, it does display as plain text, but I want to break that words by two lines.

How can I modify my template.php file with hooks, to allow html tags in menu titles?

Maybe your problem can be solved using the Menu HTML module. It seems to have been designed to solve issues such as the one you describe.

  This very simple module adds a checkbox to the menu item edit form and allows the admin to add html to the menu item title. The idea is to use this for external links for which you want to display a logo of the visited site or simply to add strong on some words.


How to programmatically create views in Drupal 7 How do I programmatically create views in Drupal 7?

I would like to create a custom module that would output data as a view.

Is there any documentation on how to output views from a custom module?

My first guess was to create a desired view using UI, export it and paste the generated code into own module.
And I guess this is how admin_menu installs their admin views. You could install the module just for testing and see the contents of /admin_menu/admin_views/views_default/. At any rate, you would have to resort to writing a custom module and adhere to views' hooks syntax.


How to get URL value in drupal? My URL is something like this http://xyz.com/content/show-cat?catid=2  . Now i want the value of catid (i.e 2) and save it in a variable. I wrote php code like $store=$_Get['catid'];

But this format is not accepted in drupal. How can i implement this? Is there any alternative?

Try $store=$_GET['catid']; instead as PHP is case-sensitive.


Inline image not showing I have a problem after my successful migration from D6 to D7 where all inline images are not showing. Inline images are the images that are inserted in node body.

Modules being used:

Insert
Custom module

This is working fine in D6 but in D7 after saving new node the image is not showing. I have to clear the cache first or resave the node in order for the inline image to show.

Steps to replicate the problem:

Create a new node and save - No inline image showing.
Visit old nodes - No inline image showing.

My solutions so far.

drush cc all
Visit the old nodes then truncate cache_field table
Resave the node

Im wondering why the inline image is not showing in newly created node and for the nodes that are not visited yet.

Any thoughts?

1) When you are adding a new node, check the text format option under the Body field. Ensure that it has not been set to "Filtered HTML" (if you are using the Standard profile) or some other text format that will filter out HTML tags outside a preset whitelist. However, this doesn't explain as to how the image shows up on re-save.

2) Disable your custom module and try once. Ensure that it is not affecting anything. Because, Insert, by itself, seems to be okay. Just checked out this demo.


Create videoplayer shortcode module for drupal 7 I have a custom player I made (Using flowplayer) and would like to make a short code for the id of that player. For example, when the user pastes [myplayer 12345], it will display that player with the appropriate video.

Can anyone point tell me how to do this in drupal?
I know in wordpress it's simple like this:

add_shortcode('myplayer','myplayer_video');

    function myplayer_video($attr) {

    $output = '<iframe width="448" height="282" src="http://mysite.com/embed/' . $attr[0] . '" frameborder="0" allowfullscreen="false"></iframe>';

    return $output;
}

My understanding is I need to make a module and I have looked at many tuts on making modules in drupal, but none on how to access the content field and diplay something or php code.


Add checkbox setting to a multiple value field I have an image field with unlimited values. I want to add a checkbox to each image to use this image on the homepage. I would then check for that value in tpl file. How do I add a checkbox setting to this field?

Looks like a user did it in this post but didn't state how: Add a configuration checkbox in field setting

You need to use field collections to group fields together.. Field settings is used for field configuration...

According to your requirement you would like to choose for each field value associated value to track whether image should be displayed or not in home page.. Field collections does this and have integration with views..


filter criteria: current users role I am using views to show some published content. I would like to give users with the role preview the ability to see all content within the view – published and unpublished. So they can preview how the page would look like after publishing content. My thoughts: I need to add a filter-criteria:

Published (=Yes)
 OR
Current-User-Role (=preview)

Ideas?

edit #1: to make it easier, I could also allow to see the content for all authenticated users.

edit #2: I have about 15 views where I need the preview functionality. they have different structure (filter criteria, viewmode, context etc) that means I need to keep it flexible. means probably that I need to define a filter and validate the data in the template.php

As said in the comment: If you want to give user access to unpublished content you can have a look at view_unpublished

You can also try to use this in combination with the 'Content: Published or admin' filter, but I didn't have a change to try it.

A filter like you're describing can be a good addition to views, consider creating an issue for it.


search and facet api tables dropped during module updates We recently added search-api and facet-api functionality to work with a new Drupal 7 view, and now whenever certain module updates are performed using Drush, one or more of the following tables are found to be corrupt or missing:

  search_api_db_00_facet,
  search_api_db_00_facet_field_facetname,
  search_api_db_00_facet_text,
  search_api_db_00_search,
  search_api_db_00_search_text,
  search_api_db_00_facet,
  search_api_db_00_facet_field_facetname,
  search_api_db_00_facet_text,
  search_api_db_00_facet_text_1,
  search_api_db_00_search,
  search_api_index.sql,
  search_api_server.sql

After these tables are restored from backup all is well again. We are using MyISAM table format in the database. No error message displays in the Drupal log until after this has occured. Search module is being used for whole site, while search-api is used for one application. Website is medium sized. The application created by content type and view contains 44,000 nodes. Is this a MySQL problem, such as a need to convert to INNODB, a search-api issue, or a facet-api issue? This doesn't seem to be a common occurrence.

This issue is resolved, thanks to an insight rocketeerbkw provided about the drush up process. I changed my user umask setting to 022 in .bashrc to be more permissive for files that my account creates on the server. This completely resolved the database table dropping issue. Before I changed the umask, I had been running drush using my normal user account with a private umask setting, and when drush downloaded new files for updates, the resulting strict permissions broke any cache rebuilds that might have been involved and also on occasion broke the database connectivity. This was neither a MySQL nor drush issue.


Is there any way to tell when a user's password was changed? A user tried to log on today and discovered that his password had mysteriously been changed. All I can assume is that he left his computer unattended and someone changed it.

Is there any way to tell when this happened, so as to narrow down who might have done it? I suspect the answer is "no" - I don't see a watchdog entry, and in /var/log/mysql all there is is an error log, not a log of queries.

Is there another place where DB queries might be logged or is there somewhere else in Drupal I could check?

It is not possible to tell from the database it-self when user changed his password.

The user password in Drupal 7 is stored in users table with the following columns of interest:

pass - User's password (hashed).
access - Timestamp for previous time user accessed the site.
login - Column which tells you timestamp for user's last login.

However there are few workarounds:

If you've got logging enabled (dblog or syslog), Drupal logs when particular user has logged in. This should point you to the IP address (whether it's different as usual).
On live environments, periodical backups of database should be a must. Depending how often you do the backups, compare different dumps focusing on particular user and his password, for example:

gzcat db-dump-2017*.sql.gz | grep -w users | grep -w pass | grep specific_user

Note: Above command attempts to stream compressed dump of database in order to find value of pass column from users table for the given user.

Then check which database dump has the new changed password. From there you can check the logs (e.g. from watchdog table) for this user. Especially check IP addresses, requested URLs and authorization attempts (whether successful or failures).


How do I hide render elements if a checkbox that controls a form #state is checked? I have a form where a user can either choose a gallery field to populate or a video field to populate but they have to choose one of the other -- there can't be a video and gallery on a page.

The logical way to do this is make three seperate content types, an article, a video and a gallery. However, since they all function about the same and an article could be about a video or a slideshow. Nevertheless, there isn't a case where a slideshow and video should be together. If they user wants video and images they can embed images through wysiwyg.

Using the #state mechanism, I have a select radios field that has the option of none, video, or image / gallery. This is set to hidden in the content display interface. If they choose image then the file field widget shows and if they choose video then the youtube field shows (once again I could use Media but that is huge and overkill for this application.)

The interface is quite sweet.

.

However, there is a problem because here a slideshow gallery has been created before the user decided to use a youtube video embedded.

What is the best practice for hiding the image gallery if the Youtube setting has been choosen? Do I make the media setting visible and then hide it and the image gallery? This doesn't make good sense because it is processed and therefore ineffient doing extra work. I don't want to force the form field to be deleted because then the work is lost. It just shouldn't be processed rather than have work deleted in the case the user would like to revert from one to the other. Any ideas?

EDIT:

I tried this code which works but I don't know if it's the best practice.

function helper_preprocess_node (&$variables) {
  switch ($variables['type']){
    case 'article':
      if (isset($variables['field_article_media'][0]['value'])){
        if ($variables['field_article_media'][0]['value'] == 'gallery'){
          unset($variables['content']['field_youtube']);
        }
        if ($variables['field_article_media'][0]['value'] == 'video'){
          unset($variables['content']['field_image']);
        }
        unset($variables['content']['field_article_media']);
      }
      break;

    default:
      break;

  }
}

You are right, a 3rd party module is overkill for this! I often find myself using a small js file to spice up the #states behavior. You can pretty much even bybass #states totally with this mecanism, but hey. #states is the drupal way of doing things. That does not mean it can't be assisted with JQuery.

Here is a quick snippet of my current quick project that is a form in a webform using the techniques (#states + jQuery) to tweak many things in the ui depending on what options are selected. This code should be in a .js file, loaded in module by the module's .info file, or you can have it in a drupal_add_js call.

I left all in there so you can see how with jQuery you can control fieldsets, option boxes and most anything you can think of. Notice also if you fancy as a bonus you can integrate all the jquery native animation functions like fadeIn() fadeOut(). There are also examples of that in the code below.

(function ($) {  // Notice code is in a behavior, use your module name
  Drupal.behaviors.yourModuleNameHere = {
    attach: function (context, settings) {

  // On load hide stuff. This will be shown when options are selected.
  $('#webform-component-inscription--enfant-1').removeClass('collapsed');
  $('#webform-component-inscription--enfant-2').removeClass('collapsed');
  $('#webform-component-inscription--enfant-1').hide();
  $('#webform-component-inscription--enfant-2').hide();
  // $('.form-submit').hide();

  $('#webform-component-inscription--information-supplementaire').hide();
  $('#edit-submitted-inscription-nombre-denfants', context).change(function () {

    var selected_option = $(this).val();

    if(selected_option === "1"){
        $('#webform-component-inscription--enfant-1').removeClass('collapsed');
        $('#webform-component-inscription--enfant-1').fadeIn(800);
        $('#webform-component-inscription--enfant-2').fadeOut(800);
        $('.form-submit').fadeIn(800);
        $('#webform-component-inscription--information-supplementaire').fadeIn(1000);
    }
    else if(selected_option === "2"){
        $('#webform-component-inscription--enfant-1').fadeIn(800);
        $('#webform-component-inscription--enfant-2').fadeIn(1500);
        $('#webform-component-inscription--information-supplementaire').fadeIn(2200);

    } else {
          $('#webform-component-inscription--enfant-1').fadeOut(800);
          $('#webform-component-inscription--enfant-2').fadeOut(800);
          $('.form-submit').fadeOut(800);
          $('#webform-component-inscription--information-supplementaire').hide();
          console.log("in extra information.");
         // $('#webform-component-inscription--enfant-1').addClass('collapsed');
        //  $('#webform-component-inscription--enfant-2').addClass('collapsed');
        }
      });
    }
  };
}(jQuery));

Of course, this method I am using  only acts on the presentation layer, if the fields you want to act on needs to be validated,  a server-side call is probably needed anyways and your method is probably better in that case.


How to make a module contribution I find some bugs in a contrib module I have fixed them and I want to commit my change to that module ,what is the right procedure to do that .

I did this is that ok.

create a new drupal site instlation.
cd to the module folder then clone the module git inside it (following the Version control instruction page)
I have fixed the problem , then commit and push to the git repo.

the problem with this method is that I can't explain the problem in detail with a just a commit so should I open a module issue in drupal website and link it to my commit ?

Until pull requests on https://git.drupalcode.org become a thing the procedure still is basically as follows:

Create an issue in that module's issue queue on drupal.org.
Git clone that module's repo and checkout the branch where you wanna fix something.
Fix the bug.
Create a patch: $ git diff > [project_name]-[short-description]-[issue-number]-[comment-number].patch
Upload that patch in the issue from step 1. and set the issue to "Ready for review".

Now everybody finding the same bug can apply that patch at best using Composer and maybe cweagans/composer-patches until the patch got committed and released by one of the module's maintainers.

The full documentation can be found on drupal.org:

Making a Drupal patch with Git
Advanced patch contributor guide.


How to save custom theme settings in a subtheme? I've created a subtheme of the Premium Responsive theme. It was working fine until I tried to change some of the advanced theme settings within the subtheme's Appearance page. The parent theme adds settings for configuring social icons, a slideshow, etc., but unchecking some of the custom options and submiting the form resulted in a message saying "The configuration options have been saved", but the settings were returned to checked.

At first, I thought I needed to copy the theme-settings.php to my subtheme and customize it, but that results in two sets of settings displaying on the Appearance page, one for the parent theme and one for the subtheme (plus, still neither set of settings would stay unchecked when I submitted the form). This seems odd, since the Creating a sub-theme documentation, says "Theme settings set via advanced theme settings' theme-settings.php are not inherited."

So, how am I supposed to set custom theme settings within a subtheme? Do I need to implement a theme-settings.php file within the subtheme or not?

I ran into the same issue. After doing an analysis I found the following:

THEME_form_system_theme_settings_alter is called for the base theme and then for the sub theme. It's not really a hook as they say - "Implements hook_form_FORM_ID_alter().".
The base theme uses things like theme_get_setting('asdf_asdf', 'responsive') to get the default values for the settings form.
The settings you're saving are saved for the sub theme.
In templates settings are returned also using theme_get_setting('asdf_asdf', 'responsive').

Because of #2 and #3 the settings appear to not be saved.

Maybe they should have used theme_get_setting('asdf_asdf'). So it will default to the current theme. It can be used in both cases: #2 and #4. It would have worked fine.

For the sake of not altering the theme and because of #4, I would remove the extra settings in SUB_THEME_form_system_theme_settings_alter so you can modify the settings only in the base theme configuration page.


Per instance settings on blocks with context? Blocks normally have a single global configuration.

What options are there to provide "per instance" settings on blocks, so that I can vary them depending on where they are displayed, when they are handled with Context?

If you use Context module for block positioning - you don't need to make any changes at /admin/structure/block page.

All configuration are done in context /admin/structure/context

If you need to display the same block on different places/pages/regions - just create different context for each condition.


What is the hook_views_data base field? Looking at the documentation for hook_views_data(), I see this:

$data['example_table']['table']['base'] = array(
  'field' => 'nid', // This is the identifier field for the view.
  ...
);

What exactly does identifier field mean? Is it supposed to be the primary key of the table? If so, what if the primary key is composite? Or if not necessarily primary key, why wouldn't it be?

With base you can tell views which table to start from

base is a sort of meta data for the views. It describes what would be the primary key of the table, what should be the views title in creating views and some help for the users to use this custom views.

field define the primary key of the custom table you want to show in views.
title is the title that will appear in your show dropdown on add view page.

EDIT: field is not a required field but its good to tell your view what is the primary key of your custom table. In case of composite key you can define both your columns in array(key1,key2)


D7, AmazonS3, composer_manager and awssdk libraries understanding I have been struggling with the installation of amazonS3. Although I was finally able to have it working pretty well, I would like to confirm with experts my understanding of the problem, and check that I got it right.

This is what I did :

installed composer_manager
installed with drush awssdk and awssdk_ui.
installed amazons3 module
while composer_manager states that all required libraries were installed, drupal status report still says that awssdk fails to load.
S3 is working fine and stores files attached to  a node.

I think I understand my mistake: with Composer Manager installed and all requirements met, I don't need awssdk and awssdk_ui modules.

These modules check that the libraries/awssdk/sdk.class.php is present, but composer_manager install the required library in vendor directory.

With this understanding, I disabled AWS SDK for PHP and awssdk_ui, and it seems to work well.

I believe that i have read to much docs on the Net, and mix two incompatible ways to install amazonS3.

Do I have the right understanding?

In the last days, I have repeated the painful procedure many times on different AWS EC2 instances to be sure to have a precise and repeatable procedure.
I am thus very confident about my understanding of it today.
I have written a step-by-step procedure to deploy amazonS3, with the main encountered problems and how I dealt with them. I believe that such a document would have helped me a lot some days ago (and back then, I didn't found any), so here is my proposal. I would appreciate some real experts validation there !

1) install Drush or update to get 5+ version

2) apply all valid patches from the amazonS3 README (https://www.drupal.org/project/amazons3), mainly to allow S3 generated URI s3:///filename.ext" to be supported by media and fileentity related modules

3) Install composer (goes without saying, but I missed it at first!) with :

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
alias composer='/usr/local/bin/composer.phar'

composer command should return usage tips

4) Install PHP's cURL extention. On Ubuntu, sudo apt-get install php5-curl is sometimes not enough. (See "cURL library required to enable drupal ...")

sudo apt-get update
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
sudo /etc/init.d/apache2 restart

5) From the drupal_root folder, launch amazons3 download and install

drush  dl composer_manager
drush  en composer_manager

6) Configure the directory where to put vendor and composer.json files. The default directory are outside of Drupal's directory (vendor : "../vendor", composer: "../")
Once the composer_manager is enabled, I went admin/config/system/composer-manager/settings  and set the fields as follows (again, refer to best practices for RW permissions of Drupal folders).

7) Be sure to give write permissions to www-data to the folder. Especially with the folder being outside of the drupal_root folder.

8) Download and install amazonS3 using Drush and composer, since AWSSDK libraries will be automatically installed with all dependencies.

drush dl amazons3
drush en amazons3

These commands should automatically generate composer.json in the previously indicated folder. You can check that all the dependencies were correctly gathered from amazonS3 and other modules requirements.
In my case, composer.json contains :

{
"require": {
    "aws/aws-sdk-php": "2.8.5-p1",
    "capgemini/drupal_doctrine_cache": "0.0.1-p1",
    "doctrine/cache": "~1.4",
    "php": ">=5.3.0"
},
"config": {
    "autoloader-suffix": "ComposerManager"
},
"require-dev": {
    "phpunit/phpunit": "~4.6",
    "satooshi/php-coveralls": "0.6.*"
},
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/deviantintegral/drupal-doctrine-cache.git"
    },
    {
        "type": "vcs",
        "url": "https://github.com/deviantintegral/aws-sdk-php.git"
    }
],
"autoload": {
    "psr-4": {
        "Drupal\\amazons3\\": [
            "../../modules/contrib/amazons3/src/"
        ]
    }
}

}

9) I can't explain why, but the first install generated an incomplete composer.json . You can regenerate the file using by accessing /admin/config/system/composer-manager and click regenerate, or running from drupal_root folder the following drush command :

composer-json-rebuild

9bis) You can also, directly from the composer folder (which location was set previously) and run :
composer install. The command will download all required PHP libraries in composer vendor's folder.

I personally found it very confusing all the locations on my server where composer files where located :

Some docs advise to put composer folder in a ~/.composer/vendor folder in user's home directory. - - Drupal created a .composer in a .drush/composer (to indicate that Drush is required for that user)
I found a ~/.composer in my root folder. It contains users's credentials to access github repository to load the required packages
Most of the docs recommend to store a composer folder just above the drupal_root
I choose to follow these last recommendations to put it in the sites/all/libraries/composer in order to commit the code. But I can't say whether this is the right way to proceed.

10) Finally, retrieve you AWS API KEY and AWS SECRET KEY from console.aws.amazon.com and  configure amazonS3 in /admin/config/media/amazons3, by setting your Security Credentials: Access Key ID and Secret Access Key, and S3 Bucketname. You can also put the values in the settings configuration file, by adding the following lines to your settings.php :

$conf['amazons3_key'] = "<AWS API KEY>";
$conf['amazons3_secret']="<AWS SECRET KEY>";
$conf['amazons3_bucket']="<bucketname>";

11) AmazonS3 should be working : create a file field on a content type, select Amazon S3 as the location to save to. Create a node, attach a file,Save and view the node. The attached file should be displayed as a link to you S3 bucket.

During  my last install, I was able to avoid most of the problems encountered in my previous tries : cURL, read/write permissions, composer unable to parse version requirements, etc.
The last error I was confronted to, was a composer out of memory problem, which I fixed with the following :

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

I hope this note will help someone, since S3 really worth a few headaches with the installation. Besides, the last release of the module is only two months old.


How do you render a table within a custom module in drupal? I have a page on my Drupal module that is responsible for the input of goals to be completed by an admin. What I would like to happen is have all of the goals within the database table render below the input form. However the only thing that gets outputted is the description tag. Using the DBA module I can plainly see a populated achievements table so I assume that the code to call and render the table must be wrong. Does anyone see where I went wrong?

I have the following code...

function achievementList_form($form, &$form_state) {
$form['generateList'] = array(
    '#type' => 'item',
    '#description' => 'This is the achievements table',
    '#value' => achievementList_generate_table(),

);

return $form;
}

and

function achievementList_generate_table() {
$query = db_query('SELECT * FROM {achievements}');

$table = array(
    '#theme' => 'table',
    '#header' => array('NID', 'Name', 'Description', 'Points'),
    '#rows' => array(),
);
foreach($query as $row) {
    $table['#rows'][] = array($row->achvmntID, $row->achvmntName, $row->achvmntDesc, $row->achvmntPts);
}

return $table;
}

Here's a tutorial which should answer your question:
https://www.drupal.org/node/156863

It's difficult to say much about the way you're querying the database without knowing more about how your data is stored. I will say that you might benefit from defining an Entity type for your achievements.

When it comes to rendering the table you should be returning the output of the 'theme' function, passing 'table' as the first arg, then the header and rows as the second and third:

return theme('table', $header, $rows);

The API page for your version of Drupal will tell you how to structure those variables:
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7


How to show only published node in Drupal Facets (Facet API + Search API)? I have some taxonomies and node belongs to these when i have created search with facet then all node displaying(publishe + unpublish). i want only published node will show.

You need to click the "Filters" tab in your search API index, then check the  "Exclude unpublished nodes" option.


How many products can Drupal Commerce handle? Are there any limitations on how many products Drupal Commerce can handle?

Interesting question. The major limiting factor for any Drupal Installation is server resources. If you have unlimited budget, it's safe to say you can have unlimited everything. There are upper limits to the architecture, but it's probably a limitation of database structure, that can be avoided by using a different kind of database.

For Drupal Commerce, the biggest limiting factor in Drupal 7 is usually not number of products (one of the companies I've worked with in the past did some tests with millions of products, and it worked just fine), but it is number and frequency of orders. A really busy ecommerce site is dealing with thousands of orders per hour.

I've personally seen tuned Commerce installations that can handle that kind of traffic at peak times and not crash. It takes a very dedicated team to scale any resource like Drupal Commerce to such heights.


How to an Add to cart Button to a Content Type? Is there a possibility to show add to cart button in node page.

Requirment:

Node will be created along with price
Add to cart button needed in that content type
Users can click on "Add to cart" button
Then ask for the payment like credit card, paypal.

I dont want a huge functionality like Drupal Commerce does. No products, products sku.

Any suggestions or any ideas about how to get this to work?

Below are 2 possible alternatives for setting up a simple shopping cart without using the Drupal Commerce or Ubercart modules (as in your "I don't want a huge functionality like Drupal commerce does. No products, products sku.").
Option 1: A lightweight e-shop
If you're only looking for a simple and lightweight e-commerce solution, have a looking at the Light Shop module (for D7, not for D6, not (yet?) for D8). Here is a quote from its project page:

Session-stored basket.
Adding to basket and its subsequent editing/checkout process is done using AJAX. Also it works fine when JavaScript is turned off.
Node based shopping. As the product can be assigned to any node type. One or more. With full support Field API features (regarding nodes).
Orders history. For each order will be created a separate node.
There is no dependence on other modules.
Full support for working with anonymous users
Integration with Views.

Option 2: A simple shopping cart
If you're only looking for a shopping cart, have a looking at the Basic Cart module (for D7, not for D6, not (yet?) for D8). Here is a quote from its project page:

Basic cart is a very simple shopping cart / checkout process for Drupal, that just sends 2 emails after each order. Along with the shopping cart, this module also provides a block where you can view your cart's content. It's ideal for small websites with only a few products or other content types being sold, for example touristic offers.
Main difference from Ubercart and Commerce:
The main difference from Ubercart and Commerce is the possibility of choosing the content types that can be added to the cart. It also doesn't bother you with the Product SKU, that can be a pain when you have just a few products.
Features:

The possibility of choosing the content types that can be added to the cart.
The possibility of sending, or not, an email to the customer once an order is placed.
Custom email messages for both the site administrator and the customer, along with the order details.
Order registration and listing in the administration area using Views module.
Integration with Rules module.
A block with the contents of your shopping cart.

Here is a screenshot of it (note the "Checkout" button also ...):

Note: According to "Payment/Basic Cart integration" it should be possible to integrate this module with the Payment module. Though that integration is still outstanding. So while waiting for that to ever get delivered, it looks like you'll have to investigate yourself to what extend this Payment module is usable in your case without that integration. As an alternative: contact the module owner to see what kind of sponsorship may get it delivered soom.


Why the path alias is like http://domain/http://domain/path? Adding a simple alias for media [media:url] causes the domain to be listed twice in the URL on media listing page in admin, for example http://domain/http://domain/path. How do I change it to http://domain/path?

I ended up using a different token which fixed the issue. I believe using token URL in the URL field is the cause of the double URLs.


How to change the url alias after a username change? I'm using pathauto to username paths (/member/[username]). After changing a username the url alias doesn't change and the user edit page doesn't have an option to change it manually.

Is it possible to change it with a rule?

Yes, you should be able to do this with a rule.  Something like the following:

Event: 'After updating an existing user account'
Conditions: 'Data comparison'.  Compare account-unchanged:name to account:name and make sure you negate, so the rule is fired when they don't match (i.e. when this field has been updated)
Actions: 'Create or delete any URL alias'.  THis should be under the 'Path' section.  Select account:url and create a new value for it

Hope this helps!

Rules export:

{ "rules_change_user_url_alias" : {
    "LABEL" : "Change user URL alias",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "path" ],
    "ON" : [ "user_update" ],
    "IF" : [
      { "NOT data_is" : { "data" : [ "account-unchanged:name" ], "value" : [ "account:name" ] } }
    ],
    "DO" : [
      { "path_alias" : { "source" : "user\/[account:uid]", "alias" : "member\/[account:name]" } }
    ]
  }
}


No suggestions in Data Selector (Rules) following this guide to display alternative prices for certain roles: http://jamestombs.co.uk/2012-09-14/drupal-commerce-different-prices-different-customer-groups

But for some reason I don't get any suggestions or dropdown in the Data Selector field.

I've tried changing jquery versions which doesn't correct the error.

Any other ideas? I've added a detailed description of my approach below the screenshot.

It's a d7 commerce site, all modules is the latest versions

Step by step approach to making the pricing rule

created 'retailer' role
added a new field of the type 'price' called field_ppd (ppd = price per dealer)
created a 'retail price' rule at admin/commerce/config/product-pricing/rules/add
added a 'Entity has field' condition
And it's in the condition config I'm stuck since the Data Selector field doesn't auto-suggest when I start typing

It is a bug in the rules module. The issue is discussed HERE.
You can either apply the patch in the issue or use the latest dev version of the jquery update module which allows you to select the drupal default version of jquery for the backend.


How to mark a node as read per user? I'm wondering what the best solution is to mark a node as read per user.

The below scenario is what I am trying to achieve:

Admin creates a node which requires to be read and confirmed and flags user a+b.
User a+b receives an email staying there is a new content that requires them to read it.
User a goes to the page and reads the content and clicks "I confirm I have read this" which cannot be reversed by user a.
When admin views the page they can see that user a has confirmed read but user b hasn't.

My first initial thoughts was to use a combination of Flag, Views and Rules.

Any suggestions?

Using the Flag, Views and Rules modules (as in your question) is indeed a way to get this to work. But assuming you have way more then just 2 (= a+b) users, you probably also want to add the Views Bulk Operations (VBO) module to this. Read on for more details ...

  Admin creates a node which requires to be read and confirmed and flags user a+b

Use Flag to create a (1st) flag to flag your nodes, and which at first will be used by the admin to set the flag for "user a+b" (as in your question), as further detailed below. The labels for this flag could be something like this:

to flag: "Confirmation outstanding".
to unflag: "Confirmed".

To actually set the flag for user a+b (imagine you have dozens ...), you should create an appropriate view (using Views) to create a list of such user a+b. And use Views Bulk Operations (VBO) to transform that view, so that the "operation" to be performed by that VBO-list is to execute a Rules Component (created with Rules).

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". You may also want to watch the subsequent "Using Rules components with more than one parameter" video.

The actual Rules Component to be used by this VBO list, is simply a rule to flag a node by a single user. The trick here is the value to use as flagging user: it should use the uid as contained in the VBO list row being processed (so not the current uid, which would be the admin using the VBO list).

  User a+b receives an email staying there is a new content that requires them to read it.

Just enhance (extend) the Rules Component from the previous step to add an additional action, which is to also send an eMail to each user being processed. Tune the subject and body of the eMail to fit your needs.

  User a goes to the page and reads the content and clicks "I confirm I have read this" which cannot be reversed by user a

Use Flag to create a (2nd) flag with labels for this flag that could be something like so:

to flag: "I confirm I have read this".
to unflag: "I already confirmed to have read this".

When user a visits this page, all that's needed is that user a clicks the link which says "I confirm I have read this". After user a flagged it like so, the (1st) flag set for the node by user a needs to be removed (= unflagged). That's something you can do with a 2nd rule, which looks like so:

Rules Event = after flagging (with 2nd flag).
Rules Action = unflag (with 1st flag)).

However, after user a flagged the node (with the 2nd flag), the link to unflag it again will be shown. But you don't want user a to be able anymore to unflag it again. To prevent that to happen, a possible solution is to create a 3rd rule to either disallow such attempt to unflag, or to capture such attempt and automatically flag it again. Another approach could be via a custom template, which will simply hide the unflag link.

  When admin views the page they can see that user a has confirmed read but user b hasn't.

Create a Views block to list all users who have not flagged the node anymore with the 1st flag (these would be your users like a). And a similar block to list all users who have still flagged the node with the 1st flag (these would be your users like b).

Note: the above approach is entirely entity based, and may be considered as a possible alternative to some of the facilities provided by the Legal module (your question might be about similar functionality).


Adding JavaScript just to one node I have added scripts[] = js/add_property.js to my .info file which works perfectly.

That loads the JavaScript for every page though, so how do you do it so that it only loads for the .tpl that it is used in?

If you want to add the Javascript to a single node, you might also implement hook_node_view:

<?php
function my_module_node_view($node, $viewmode, $langcode)
{
  if ($node->nid == MY_NODE_ID) {
    $node->content['#attached']['js'][] = array
    (
      'type' => 'file',
      'data' => drupal_get_path('module', 'my_module') . 'js/add_property.js',
    );
  }
}
?>

(Solution adapted from https://www.drupal.org/node/1993228).


How do I programmatically update the rendering language? I am trying to programmatically set the Views rendering language of a couple of Views having multiple displays. I found that doing it manually is error prone.
use Drupal\views\Views;

$view = Views::getView('ap_country');
print_r($view->display_id);

$view->setHandlerOption('page_2', 'argument', 'nid', 'admin_label', 'Foo');
$view->save();

I am trying to achieve something like the above and then export the View. However rendering language does not seem to be a handler.
The reason behind dong this is currently all the views are set to the current Interface language and I want to switch to the content language.

Yes, this is not a handler setting. This is configured directly in a display.
To update a View programmatically use the storage property of the View object (which is by the way a reference to the config object discussed in the comments) and get a reference of a display (the master display is default):
$view = \Drupal\views\Views::getView('myview');
$storage = $view->storage;
$display = &$storage->getDisplay('page_2');
$display['display_options']['rendering_language'] = '***LANGUAGE_language_content***';
$storage->save();


Context Node Add Form and Wrong Button Position I created a context node add form and added it to the panel page.
The form is displayed in the page but, "Save" button is wrongly positioned.

Another form also has the button wrongly at the top instead of bottom.
I updated the button's weight from my custom code to move the button underneath of the form, but it doesn't work.
I used CCK fields in my form.
I'm looking for a fix.

Have you tried adding the submit button separately from the contact form?

If you are using an override to the node add/edit form in panels, try this:

1. Click on the little gear of your region to add content

2. Select Node form submit buttons which is under the "Form" heading

3. Position the form submit buttons where you want.

We had a similar problem on a Drupal 6 installation, and I think it may work on Drupal 7 as well.

Hope this helps


When translating a node, can I avoid copying the default value from the original language Just a little background:  I've got a set of paragraphs fields that I need to be able to translate, and given the limitations on translation with paragraphs, I've come up with the idea, that it may just be best to create a new node of a new content type (for holding the paragraphs fields) for each language of the main node.  I would then use Inline Entity Form to bring those fields into my main node.

The problem I run into is that translation copies the value from the original language when I create a translation.  Most of the time this is desirable, but in this case, it means that all languages get the same referenced node, when I specifically want them all to have their own new node.

Is there any way to suppress the value copy functionality for a specific field when translating?

Unset the field values in a hook_ENTITY_TYPE_translation_create:

use Drupal\node\NodeInterface;

/**
 * Implements hook_ENTITY_TYPE_translation_create().
 */
function mymodule_node_translation_create(Nodeinterface $translation) {
  if ($translation->getType() == 'product') {
    unset($translation->body);
  }
}


Menu link to the most recent article with a certain taxonomy term I am using Drupal 7 and have been trying to figure out following:

How do I make a menu link to the latest article that has been classified with a certain taxonomy term? For example, I want to have a menu link called ‘Lifestyle’ and by clicking that I expect to get the most recent article classified with taxonomy term ‘Lifestyle’. For SEO purposes I prefer if the menu link would contain the title of the article.

I tried to do this using Views module with basic filters, but I have some issues with this approach:

As a result I do get a latest article with a certain taxonomy term, but the page title is displayed twice (the first one is a link to article itself). How do I remove this properly in a Drupal way (I don’t want to use CSS to hack it).
Also, as a result, Views generated URL that looks like this: http://www.mydrupalsite.com/articles/latest/1 (where 1 is a taxonomy term id). I would like it better if the URL would point directly to the node like this: http://www.mydrupalsite.com/articles/the-article-title-here

Any ideas?

Thanks.

For your first question:

As your are displaying "Teaser" view of the node in your view, so you are getting two title of the node. If you want to hide the "Title" of the node and display the override title, then you can follow the below step.

Go to Administration -> Structure -> Views
Edit your views "latest"
Click on "Content" in "Show" setion under "Format" section of your views, it will display the popup.
Select "Fields" from form which is opened in popup and save the form.
Now, you will see "Title" and "Body" in your "Fields" section.
You can remove the "Title" from views or Edit "Title" fields and check "Exclude from display" check-box, so it will not display in views.

For Question 2:

If you want to append latest node title with path (latest), then I do not think, there is solution for this.

But, if you install "pathauto" module, then you can create url alias for the same or you can append term name with view path and can get term id for the term name.


If taxonomy vocabulary changes from Translate to Localize how to combine terms? My d7 is using i18n, internationalization taxonomy. I have vocabulary that have option Translate. So it looks like (eng, de):
Creative
- Projects
- Portfolio
Kreativ (de)
- Projekte (de)
- Portfolio (de)

These terms have relations between one and other. Really I have about 150 terms and  want to simplify this vocabulary. Need to change it to Localize option. If I will check Localize all terms beacame independent (single) so this is very very bad.
How to combine all of them, please?

Looks like you should consider using the Taxonomy Manager module. From its project page:

... provides a powerful interface for managing taxonomies. A vocabulary gets displayed in a dynamic tree view, where parent terms can be expanded to list their nested child terms or can be collapsed.
The Taxonomy Manager has following operations and key features:

...
merging of terms (using the Term merge module in 7.x)
...


Form AJAX - Update button value via Ajax I have a custom form in Drupal that ties into Entity-generating code. In essence, there's a button which should return an ideal Entity state (determined in a method that returns true or false).

The code below fires the method in question, but even if it gets a return value from the method, the value of the button never changes.

Am I overlooking something as simple as returning a new #value in the AJAX callback?

function example_mark_block_form($form, $form_state) {
  $form = array();

  $is_marked = _example_is_user_marked();

  $form['mark-changes'] = array(
    '#type' => "button",
    '#id' => "mark-changes",
    '#default_value' => t($is_marked),
    '#prefix' => "
",
    '#suffix' => "
",
    '#ajax' => array(
      'callback' => 'example_mark_follow_ajax_response',
      'wrapper' => 'mark-wrapper',
      'method' => 'replace',
    ),
  );

  return $form;
}

/**
 * AJAX callback for the follow response
 */
function example_mark_follow_ajax_response($form, $form_state) {
  global $user;

  return $form['mark-changes'];
}

From the FAPI Reference:

#ajax['wrapper']
This property defines the HTML id attribute of an element on the page which will be replaced by the html returned by the #ajax['path'] or #ajax['callback'] function. Usually, a div element is used as the wrapper, as it provides the most flexibility for placement of elements before, after, or inside of its HTML tags. This property is required for using AJAX requests in on a form element.  Note that the entire element with this ID is replaced, not just the contents of the element.

So this:
'#prefix' => "
",

Should be:
'#prefix' => "
",

Also buttons don't have a #default_value, so replace:
'#default_value' => t($is_marked),

with:
'#value' => t('@value', array('@value' => $is_marked)),

And you should be on track (the change to t() is just for sanitisation, see Translating Variables).


URI for actions of services I have defined the following service.

'salesforce_subscriptions' => array(
    'operations' => array(
      'delete' => array(
        'help' => 'Remove subscriptions from SalesForce',
        ...
        'args' => array(
          array(
            'name' => 'ids',
            'type' => 'string',
            'description' => '',
            'source' => array('param' => 'ids'),
            'optional' => FALSE,
          ),
          array(
            'name' => 'API key',
            'optional' => FALSE,
            'type' => 'string',
            'description' => 'The api key',
            'source' => array('param' => 'api_key'),
          ),
        )
      )
    ),

How can I access this?
The endpoint of the service is: endpoint.
I can access the index service by:
www.example.com/endpoint/salesforce_subscriptions

How can I access delete?

You should be able to access it via

www.example.com/endpoint/salesforce_subscriptions/[ids]/delete

If that doesn't work, you may need to experiment with the id parameter source, e.g path argument vs param

For more info and example, see the node resource definition here:

_node_resource_definition


show same slideshow on different sites how to show the same slideshow view on different sites but with different images - I have multiple sites which needs to show the same slideshow with different images. Can anyone explain how to go about this. I am relatively new to drupal and I have already setup the slidehow view / cycle module and created slideshow view and slideshow content type for one of the site and its working al good. Now I want to replicate the same on the other site (all the themes and the templates and css are the same its basically white labelling) but just use different images.

You should try the features module

  The features module enables the capture and management of features in
  Drupal. A feature is a collection of Drupal entities which taken
  together satisfy a certain use-case.

  Features provides a UI and API for taking different site building
  components from modules with exportables and bundling them together in
  a single feature module. A feature module is like any other Drupal
  module except that it declares its components (e.g. views, contexts,
  CCK fields, etc.) in its .info file so that it can be checked,
  updated, or reverted programmatically.

  Examples of features might be:

  A blog
  A pressroom
  An image gallery
  An e-commerce t-shirt store


is there any general or universal way to change Drupal's objects CSS? In some cases, when I install new themes, some regions\ blocks\buttons are too near to each other, and I need to start adding margins between them individually with css. This takes much time...

Is there a way to automate this process? Is there some kind of a general\universal ID or class for all regions\blocks\buttons that I might be able to use to space all of regions\blocks\buttons "In one piece" and with much comfortability? It could also help me save time that could go on other things.

No. Of course there are default Drupal styles but there are no guarantees that whichever base theme you are working from hasn't overridden them.

The good news is that most popular base themes will implement classes that are universal to a particular type of output, like a row or a block. For instance, Foundation uses its own 'row' and 'column' but retains the core 'block' class.

Since you asked :), here is something you might do to add padding to columns in a Bootstrap subtheme:

.main-container > .row > section {padding: 1em;}

Note the '>' combinator. This refers to immediate descendents.

Note: If a selector is prefixed with '#' it is an id, and will only apply to one element. A class is prefixed with '.' and can apply to multiple elements. So all rows in bootstrap can be accessed with:

.row {padding: 1em;}


How do I change base URL when moving site from sub-directory to domain root? I have developed a site in a sub-directory and now will be pointing a live URL to it. What do I need to do to ensure that the relative links in the menus etc will work under this new configuration. I have read that settings need to be changed in sites/default/settings.php however looking at the file it does not appear that a "base" URL is specified ... same with the .htaccess file under the root.
This may be a fundamental question, but in WordPress for example having a new "base" URL requires a settings change otherwise relative links will end up pointing to a 404 page ... how is this handled in Drupal (7)

Unless you have made customizations to the URL-related settings in .htaccess or your settings.php, you won't need to update anything. Simply move your site, then clear the cache either via the "Clear Cache" button (on the Performance admin page), or the Drush utility, and you should be good to go.


disable administrator role in add user form Some role in my site has permission to create users but not a administrator one.
How to disable create a new user of administrator role?
Is there a module for that?
thanks.

You can create a module that uses a hook, something like

function remove_admin_role_choice_from_add_user_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $form['account']['roles'][3]['#access'] = FALSE;
}


Callbacks order in Drupal 7 I have 2 modules (filters): html_pre_filter and syntaxhighlighter.

syntaxhighlighter_prepare_callback executes before html_pre_filter_prepare_callback.

How to reoder them?

I tried this

function html_pre_filter_module_implements_alter(&$implementations, $hook)
{
    if($hook == 'filter_prepare')
    {
    $group = $implementations ['syntaxhighlighter'];
    unset($implementations ['syntaxhighlighter']);
    $implementations ['syntaxhighlighter'] = $group;
    }
}

but it doesn't work

The code you are trying doesn't work because syntaxhighlighter_prepare_callback() and html_pre_filter_prepare_callback() are not hooks: They are simply callback functions defined in the implementation of hook_filter_info() done from those modules.

In fact, the code used by check_markup() to invoke the input format filters is the following one.

  // Get a complete list of filters, ordered properly.
  $filters = filter_list_format($format->format);
  $filter_info = filter_get_filters();

  // Give filters the chance to escape HTML-like data such as code or formulas.
  foreach ($filters as $name => $filter) {
    if ($filter->status && isset($filter_info [$name]['prepare callback']) && function_exists($filter_info [$name]['prepare callback'])) {
      $function = $filter_info [$name]['prepare callback'];
      $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
    }
  }

  // Perform filtering.
  foreach ($filters as $name => $filter) {
    if ($filter->status && isset($filter_info [$name]['process callback']) && function_exists($filter_info [$name]['process callback'])) {
      $function = $filter_info [$name]['process callback'];
      $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
    }
  }

No hook is invoked, or you would see a call to module_invoke() or similar function.

If you are looking at a way to programmatically re-order filters used by input formats, the only way I can see is altering the cache where Drupal stores the information about the input filters. See filter_list_format(), which is the function that returns an ordered list of filters used by an input format.
More easily, this can be accomplished from the user interface, since on admin/config/content/formats you order the input filter for each input format.


How do I find the source of an error? I'm seeing the following error when running cron (in terminal via drush and on screen via the status report page.

  Error: Call to a member function getScriptTag() on a non-object in /home/loktah/public_html/includes/common.inc(1762) : eval()'d code, line 2

I'm not sure where to even start looking for the source. Any direction would be appreciated.

The line 1762 is inside drupal_eval(), in Drupal 6. You need to check  those nodes that use the PHP filter and call getScriptTag() on a variable that doesn't contain a PHP object.

It happens during cron tasks because one of the implementations of hook_cron() indirectly calls node_view() on some nodes.


Show node if exists, else show node creation form I would like to setup an environment where each of my users will be creating a node every day. I know all of my users won't be able to log in every day and they will want to check what they added on past days. I figured the best way to accomplish adding past days & displaying created content would be checking the url and returning either the node (if they have created one) or the node/add form if they have not.

For example, user 1234 navigates to:
url = example.com/user/1234/2011/09/10

If they have a node created with a date field set to this day it would show the node.  If not, it returns the node/add form with a hidden field set to the date in the url (easy, I can take care of that).

My first thought was panels/page manager, but I don't see a way to check if a node is created based on a date structure, if it can be accomplished I am all ears. If you think another solution is better... I am all ears!

EDIT: It has been brought to my attention that my original question overlooked a node type.  I might have more than one, and I could see this being useful for other people so lets say for arguments sake that the url looks like this:

example.com/user/1234/[node-type]/2011/09/10

I ended up getting this to work with views, date and some custom code.  Basically I created a page view that with a conditional filter for a post date in YYYYMMDD format (a default argument provided by date), if one didn't exist I added some code in the "No Results" field that would load the node creation form with basically:

$form = node_add(arg(0));
print drupal_render($form);

So a url of /story/20110915 would show the story from that date if it existed, otherwise it would show the node/add form for the story content type.

In the final product I actually had the view load an .inc file from my custom module in the "No Results" field (also much faster than editing the view every time while developing). But I think this gets the basic point across.

Sorry @ram4nd if I made it seem like I didn't want to write code, I just was looking for the best approach.  So far this seems like it is pretty solid.


Force an image to display as block (not inline) I have a field of type image that I would like to display in a column alone, with all following content displaying beneath, even if the image width is narrower than the width of the display.
Even when using the layout builder, the following content always flows inline with the image.  The image is in a block in a single column section.  The following content is in a two-column section.  Instead of a single column showing the image followed by two columns with other content, the resulting display appears as three columns: Image of 1st section, 1st column of 2nd section, then 2nd column of 2nd section all in a single row.
Drupal version: 9.1.4
Any assistance in solving this?

This looks to be a CSS issue, not a Drupal issue. Leverage "display:block" and "min-width:100%" on whichever wrapper div you want to stay on top. But you'll need some CSS massaging and experimenting to get it working as you need.


Articles listed in custom order I have a Drupal 7.31 installation.

I have 3 rows in homepage, in which are listed 3 articles for each of them. Here a partial screenshot of Edit View for the first row, in which Sort criteria actually is set to "Publishing Date".

My customer asks me to be able to directly re-arrange the order and I found something about the "DraggableViews" module. I tried to follow two guides (DraggableViews and Custom Sort Drupal Content with the Draggable Views Module) without success.

Reasons are both:

Options and settings that I found in my installation are different from which are listed in tutorials
In both cases, I have to change "Format" in "Table" but doing so results in a wrong display template also in the website, corrupting layout. So I have to remain with "Unformatted List" for output.

It's not important that custom order is made with Drag&Drop, an order specified with dropdowns could be ok, but how to not affect view display, but only order?

You can maintain a weight field with list option enabled for your content type and sort your view from your weight(an integer). In views sort criteria section put the weight criteria top if there are any others. Same answer I gave here


D7: How do you get the name of a module? I am using module_list() to get a list of all modules, but I want the names of the modules, not their machine name. Anyone know how to do that?

You can use the system_rebuild_module_data() function to get a list of all module data in the system:

$module_list = system_rebuild_module_data();

Each entry in the array returned from that function contains all the details about the module, e.g.:

It's the same function used by the system modules admin page so I think it's safe to assume this is the best way to get this particular data.


Why is my block not showing up on the Blocks page? I don't remember where exactly my return needs to be.  It had worked at one point, but stopped at a random time.  Google'd and didn't find my answer.

function bobby_name_generator_block_view($delta = '') {
  switch ($delta) {
    case 'bobby_name_generator':
      $block['subject'] = t('Generate Bobby Name');
      if(user_access('access content')) {
        $block['content'] = drupal_get_form('bobby_name_generator_form'); // insert bobbyname variable here!
      }
      return $block;
  }
}

Here is an example for hook_block_info found in examples module. This defines the existence of block and this will make the block show up in the block page. You could use hook_block_configure to provide additional fields for you block in block page and save the it using hook_block_save.

function example_block_info() {

  $blocks['example'] = array(
 'info' => t('Example: configurable text string'),
 'cache' => DRUPAL_CACHE_PER_ROLE,
 'status' => TRUE,
 'region' => 'sidebar_first',
 'visibility' => BLOCK_VISIBILITY_LISTED,
 'pages' => 'node/*',
 );

return $blocks;
}


Add body class depending on current URL I have an URL textarea and I want to add a body class if the current URL is one of those that the user has input in the textarea.

This is my current code:

function MYTHEME_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL) {
  $form['head_footer_hiding_urls'] = [
    '#type' => 'fieldset',
    '#title' => t('Hide header and footer on specific url\'s'),
    '#description' => t('Specific url\'s to hide header and footer'),
    '#collabsible' => TRUE,
    '#collabsed' => TRUE,
  ];
  $form['head_footer_hiding_urls']['url'] = [
    '#type' => 'textarea',
    '#title' => t('Set url\'s'),
    '#description' => t('Set url\'s to hide header and footer,
 you can only write one url at a line.'),
    '#default_value' => (theme_get_setting('url') != NULL) ? theme_get_setting('url') : '',
  ];

  return $form;
}

How can I do that?

I found a solution, I wrote this in a preprocess function:

function THEME_preprocess_html(&$vars) {
  // Add body class if current url is configured to have header/footer hidden.
  $urls_to_test = array(
    $_GET['q'],
    drupal_get_path_alias($_GET['q']),
  );
  foreach (explode("\n", theme_get_setting('head_footer_hiding_urls')) as $url) {
    if (in_array($url, $urls_to_test)) {
      $vars['classes_array'][] = 'theme-hide-header-footer';
    }
  }
}


Commerce view of node checkout hides unpublished content, therefore can't relist I'm using commerce node checkout and have enabled the predefined view, Commerce Node Checkout Expire Posts (Content) to give customers a list of content they've paid to publish.

The problem is, when the content expires and is unpublished, it disappears from the view output. This is problematic because that view contains the 'relist' button, meaning that customers can't relist expired content.

Has anyone found a workaround for this? (Or maybe I'm missing something?)

Fixed:

In the view, go to: Advanced > Other > Query Settings.
Switch on Disable SQL rewriting.

Unpublished nodes should now be visible in the view.


How to get all Fields of specific FieldType? What I'm trying to do is ->

 $fields = [];
  $fields = $entity->getFieldDefinitions();
  foreach ($fields as $field) {
    if ($field->field_type == 'type') {
      $test = $field->field_type;
    }
  }

Unfortunately I couldn't find a neat method to select my fields by type, so I thought unless Drupal won't give me one I write my own.
But Drupal restrict me on that also with this ->
Fatal error: Cannot access protected property

  Fatal error: Cannot access protected property
  Drupal\field\Entity\FieldConfig::$field_type

You code is OK, only that you are trying to read the protected property field_type. Instead use the method:

$field->getType()

Reference: public function FieldDefinitionInterface::getType()


What is the recommended jQuery and jQuery UI version? What is the recommended version of jQuery and jQuery UI that I should use on a Drupal 7.77 site?
I know the latest jQuery version is now 3.5.1, but what is the recommended version for a Drupal 7.77 site?

There is usually a difference between the front end, and backend.
Some of the core displays rely on an older version of jquery.
If you install the jquery_update module, you will be able to select different versions for front end and back end - and it will tell which is the default version for Drupal Core.


how to create a static view page which gets result from a content type? Good day,
I am wondering how do i create a static page, which displays the result of content types data?
its like this: a user will fill a content type called "books" and insert data into fields like (author, type of book, published,localization).
the type of book will be a taxonomy, which will determine if the book is a magazine, novel or a research.

think of the result page as an excel file, which will have a book, and its sub categorized into field of result numbers.

my point is, i want to create a static page, which will show result of the following:

how many research books available. (a field will be based on taxonomy term)
what are their localizations, foreign, or local.

i know the a math operated result could use views_calc module, but i wanted it as an independent page viewing the report, not to mention that not all will require math operation.

so once a user fills in the content types field, result is updated to the static view page automatically (like a report) to tell what and how many books types were inserted and what are they. please refer to the pic.

to clarify further, in database coding, i would execute my intended report for 1 result as from content type like this: "select * from books where type="magazine" and published= "yes"

so result will show how many magazines published, as in the pic.

i heard about forena module, but it seemed bit too complex for my task, which i think is simple. but im not sure.

im new to the web development era, i used to do basic java SE so im trying to avoid coding everything(which is my last option).

hope i made it clear.
Thanks in advance

Looks like you need to look at some of the typical "page layout" modules, such as these ones (excerpts from their project pages):

Display Suite.

... allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!

Panels.

... allows a site administrator to create customized layouts for multiple uses. At its core it is a drag and drop content manager that lets you visually design a layout and place content within that layout. Integration with other systems allows you to create nodes that use this, landing pages that use this, and even override system pages such as taxonomy and the node page so that you can customize the layout of your site with very fine grained permissions.

Not sure if Display Suite will be sufficient for all your needs, but Panels will pretty sure be helpfull. Possibly also with 'mini-panels' added to that.
Be prepared however to invest some time in learning about these amazing modules. A great resource for learning about Panels is the (free) video training about Learn Page manager. Panels uses 'Page manager', which is one of the sub-modules of Chaos tool suite (ctools)).
And after you become familiar with these modules, you may want to consider using Forena to create special (mini?) reports to be shown in (eg) a block on your page. Possibly also using Forena's integration with the BEAN module (another module to add to your list of modules to be reviewed ...). For more details about this integration, refer to Forena's Site Building Guide.


How to hide page title based on node type using template_preprocess_page() I am trying to hide the title of the current page (as printed by page.tpl.php) if the current page is 1) a node in full display (as opposed to teaser mode), AND 2) the node type is either concert or bio. I print the node title for these content types directly in the node content, so I want to hide the duplicate being printed by page.tpl.php. I am not able to get this to work directly in page.tpl.php, and my reading suggests the best practice is to handle template logic in template.php using preprocess and process functions. So, I am trying to hide the current page title (with the above 2 conditions) using template_preprocess_page(). This is my code.

<?php
    function MYTHEME_preprocess_page(&$variables) {
        if (!empty($variables['node']) && $variables['node']->type == 'concert') {
            hide($variables['title']);
        }
    }
?>

I read How do I test for node type to print a variable from template.php? and the documentation page for template_preprocess_page(), and various other sites, but I just can't seem to get this to work. I saw suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that didn't work either. I didn't see a clear solution posted anywhere, and I'm at my wit's end.

and my reading suggests the best practice is to handle template logic in template.php using preprocess and process functions.

Decoupling the logic from the rendering code simply means the code in template.php sets a variable that is checked in the template file. In this way, the logic is all contained in the template.php file, while the rendering code is all in the template files.

template.php

function mytheme_preprocess_page(&$variables) {
  if (!empty($variables['node']) && $variables['node']->type == 'concert') {
    $variables['show_title'] = FALSE;
  }
}

page.tpl.php

<?php if ($show_title && $title): ?>
<?php print $title; ?>
<?php endif; ?>

hide() doesn't work because $variables['title'] is a string, not a rendering array. hide() is always used with a rendering array, and it doesn't have any effect with a string, not even when the string is passed to render().
Actually, passing a string (or any value that is not a reference to a variable containing an array) to hide() would cause a PHP error, since the function uses this code.

function hide(&$element) {
  $element['#printed'] = TRUE;
  return $element;
}

Unsetting $variables['title'] with unset($variables['title']) doesn't work too, as template_process_page() would get the page title from drupal_get_title().

if (!isset($variables['title'])) {
  $variables['title'] = drupal_get_title();
}


Reference node inherits taxonomy terms of referenced node This is a problem that's been bugging me for days now and haven't yet found a solution in Drupal 7.

I'll be more specific:

I have a content type named Debate and another one called Vote.
Vote type has a node reference field to Debate type.

Debate type has a term reference field (autocomplete widget, 4 values, Voting choices vocabulary) where user inserts the voting choices of his Debate node.

Vote type has a term reference field (select list, 1 value, Voting choices vocabulary) where user can choose a term to vote.

My problem is that the select list of the term reference field of the Vote node shows all the terms of the Voting choices vocabulary. What I want is the select list of the Vote node to show only the terms that come from the Debate node it's referring to.

In other words I need to filter out the terms of the Vote node based on the Debate node it's referring to, when I'm at the node/add/Vote form of course.

First you would create a form alter function and make the taxonomy field as hidden and add ajax functionality to the node reference field. I am assuming that then node reference field widget is a select list.

For the following example I am assuming your fields are in the Basic Page. you can change the function name to suite your requirement by changing the mymodulename and page.

I am assuming the field name of the term reference field is field_vote and the node reference field is field_debate

function mymodulename_form_page_node_form_alter(&$form, &$form_state, $form_id) {
  // We add the ajax functionality to the node reference field.
  $form['field_debate']['#ajax'] = array(
    // #ajax has two required keys: callback and wrapper.
    // 'callback' is a function that will be called when this element changes.
    'callback' => 'vote_field_return',
    // 'wrapper' is the HTML id of the page element that will be replaced.
    'wrapper' => 'replace_vote_div',
  );

  // Add a wrapper around the taxonomy field.
  $form['#prefix'] = '
';
  $form['#suffix'] = '
';

  // Check the form state to see if the debate field is filled.
  if (!empty($form_state['values']['field_debate'])) {
    // Load the debate node.
    $debate = node_load($form_state['values']['field_debate']);

    $form['field_vote']['#type'] = 'select';

    // Assuming the taxonomy field in debate content type is field_vote_debate
    // Some times the language for the field might be different from the language of
    // the node itself in this case you might want to look at a dump of the $date
    // field and make the required changes.
    foreach($debate->field_vote_debate['$debate->language'] as $vote_term) {
      $form['field_vote']['#options'][$vote_term['taxonomy_term']->tid] = $vote_term['taxonomy_term']->name;
    }
  }
  else {
    // Hide the taxonomy field to start of with.
    $form['field_vote']['#type'] = 'hidden';
  }
}

The call back function is pretty straight forward we simply return the field_vote so that it can be rendered again in the form

function vote_field_return($form, $form_state) {
  // The form has already been submitted and updated. We can return the replaced
  // item as it is.
  return $form['field_vote'];
}

Note: As per the comment Please find below the updated code if the node ID is coming from url

I am assuming that the url to add the vote node is as follows

http://example.com/node/add/vote/23

where 23 is the node ID of the debate content type.

function mymodulename_form_vote_node_form_alter(&$form, &$form_state, $form_id) {
  // We use the arg() function to get the argument from the url. The numbering
  // starts from 0 and the one we need would be at 3.
  $debate = node_load(arg(3));

  // Assuming the taxonomy field in debate content type is field_vote_debate.
  // Some times the language for the field might be different from the language of
  // the node itself in this case you might want to look at a dump of the $date
  // field and make the required changes.

  foreach($debate->field_please_vote['$debate->language'] as $vote_term) {
    $term = taxonomy_term_load($vote_term['tid']);
    $form['field_vote']['und']['#options'][$vote_term['tid']] = $term->name;
  }
}


Rotor banner, Toggle the display of an image banner and rotor banner view based on view results Within the page node is a field for an image that is the page's banner image. We also use Rotor banner to do rotating banner images in the same location. Since I have a default banner set for the page, pages can't have an empty banner field. If a rotor banner view exists, both the page's banner and the rotor banner display stacked on top of each other.

How can I test to see if the rotor banner view has any results and determine whether or not the field banner for the page should display or not? If there is a rotor banner to display, I want to hide or remove the field banner from display.

Both the field banner and rotor banner are living as blocks in the same region. I would like to come up with something for the "Page specific visibility settings" for the blocks, but I'm thinking I will have to do it some how within the theme.

I can't figure out how to see what nodes have been loaded other than using Firebug. If I could access those nodes in a variable accessible to the block or the theme, I could detect if there are rotor items loaded.

Does anyone have any ideas?

You can display the image field of the node if the rotator banner is empty by outputting that field into the Empty Text field of the view that you are displaying. So you would only need the view's block in the region that you have both blocks currently. Make sure you have PHP input enabled in your empty text.

If the banner content is exclusive to that node's page, you can add a Node Reference CCK to the banner content type and tie the nid argument in views the the node reference field by adding that node reference field as a relationship in your view.


How to theme views fields template to display a gallery? My question is generic because the solution will allow me to use various jquery gallery as bxslider, galleria or flexslider.
My need is about creating a gallery with thumbnail nav, for that I need to create a views display that provide this kind of code (ex from bxlsider):

The list creation is easy for mu but I don't find a way to produce the thumbnail part..the views PHP module seem to be the path (to add data attributes and create the thumbnail "list") but I don't find the right way.

If someone can help me.All of this come from that actually using Drupal 6. :/

Thanks

EDIT: use case with data from $row views object.I don't know how to print field data settings in my view as in the template to override the output.
Here I would to add the "data-thumb" attribute dynamically, provided by views data.

No difficulty to build the list in views.

EDIT2: back on my second example, I improve my code and I'm near the goal.In a views field tpl I put actually:

<?php

    $imgurl = file_create_url($field->uri);
    $img_filepath = $fields['filepath']->content;
    $img_slide_size = $fields['field_galerie_image_vdl_fid']->content;
    $img_caption = $fields['field_galerie_image_vdl_data']->content;
    print '
'
            . '
'.$img_caption.'
'
            . '
';

?>

Naturally when it'll be ok, a foreach loop will needed.But I need to clean the provided views code, because actually I put off all HTML things via the Views UI but I think it's possible to that by PHP code.

EDIT 3: my new base code to continue looking for theming my views output from unformatted content.

<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <?php print $field->wrapper_prefix; ?>
    <?php print $field->label_html; ?>

<?php
//création des variables utiles pour la mise en forme de la sortie de la vue
  $imgurl = file_create_url($field->uri);

    $img_thumb_filepath = strip_tags($fields['field_galerie_image_vdl_fid_1_value']->content);
    $img_slide_size = strip_tags($fields['field_galerie_image_vdl_fid_value']->content);
    $img_caption = strip_tags($fields['field_galerie_image_vdl_data_value']->content);
    $img_delta = strip_tags($fields['delta']->content);
    ?>

 <?php
               foreach ($fields as $key => $lien) {

                    print '
'.$img_slide_size.'
';
               }
      ?>

  <?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>

actually my variables doesn't return the right content, but I don't know how to find the right syntax.

I would recommend going via Views Templates, take a look at views-view-fields.tpl.php template. From there you should be able to duplicate and modify the views content for the thumbnail part.


How to display a table view and an add/edit form on the same page? I'm trying to build a page in my site where users can create a new project (fill out a few text boxes to give the project a title/description), see a list of all of their projects, and edit any of those projects.

I've created a new content type called "Projects" that includes all the text fields needed for creating a new project. And I've figured out how to use Views to display a list of user projects. I've tried to display these 2 elements together using Panels, but that means I need to create a new Variant for both the Node View and the Node Edit pages, which feels clumsy in terms of development. And the end result on the web site is 3 slightly different pages (one to create a new project, one when you click on a particular project to view it, one when you edit the project). But ideally, it would feel like one slick page.

Am I taking the right approach with using Panels, or is there another module or approach that is better?

Hey Erin, certainly a good way to build customized pages is use Context module instead of Panels... (Context allows you to manage contextual conditions and reactions for different portions of your site. You can think of each context as representing a "section" of your site. For each context, you can choose the conditions that trigger this context to be active and choose different aspects of Drupal that should react to this active context. Link: Context).

In addition of that, you can create a block (be sure to have PHP Filter enabled), and include the following code.

For a existing node edit form:

//you should have your nid (May be loaded by a custom arg or even a given GET variable)
$nid = 99;
$node = node_load($nid);
//load needed file from node module
module_load_include('inc','node','node.pages');
//load node edit form
$form = drupal_get_form($new_node->type . '_node_form', $node);
//print the form you have loaded
echo($form);

In case you want to load a fresh node add form, instead of loading a node with node_load, you should create a stdClass object, and give the type name just as bellow:

//load the current user info
global $user;
//empty object for node
$new_node = new stdClass();
// your machine name content type
$node->type = 'page';
// set the author for the node to be created
$node->name=  $user->name;
//load needed file from node module
module_load_include('inc','node','node.pages');
//load node edit form
$form = drupal_get_form($node->type . '_node_form', $node);
//print the form you have loaded
echo($form);

Actually it may not be the best way to do that, but certainly is a functional method.