Restrict forum access based on user (user list) I need to restrict access to forums so that only selected users can access an individual forum. (The users should apply for a forum and a moderator should decide if the user should be allowed to participate in that forum or not.)

If users visit the forum listing page for the first time, they should only see all forums listed but they should not be able to see the topics.

I have used Flag module to implement a subscription system.

I have set a flag 'subscribe_forum' that allows users to flag a forum, and another flag 'approve_forum_subscription' that allows an administrator to flag a flagging, which means the subscription of the user is accepted.

What I want to do is to grant that user access only to those forums which he has subscribed to and has been approved by an administrator.

The solution you would suggest doesn't have to use this flag system. I am open to any other suggestions.

I have installed Forum Access module, however it allows me to restrict access based on roles, but I need to have a list of users for each individual forum. The only thing that is useful for my case on this module is the ability to set a moderator for individual forums.

Edit: I am also using Advanced Forum module to extend the functionality of the core Forum.

UPDATE:

I have mostly achieved my goal using Panel pages which are already provided by Advanced Forum, adding some custom selection rules.

I have added a PHP Code rule which returns TRUE if the user has flagged the forum, and a moderator accepted it (i.e. flagged the flagging of the user), and FALSE otherwise. I have also added a fallback variant which shows only an 'access denied' message in a panel pane.

I have done the same thing to the topic listing panel, as well.

Then, I have enabled the panel page that overrides node/node% and added 2 selection rules, one for checking if the content type is forum and the other one is the custom PHP.

So, I have almost what I wanted to have, but I am not yet completely sure if this method I follow is a good one. To be honest, I don't find it elegant enough.

I am still open to other suggestions. It can also be a completely different approach.

Thanks in advance.

If you use views or panels to display the forum, you can use their access controls which are quite flexible. Doesn't look like AF has built views for everything, so I think the easiest way would be to use Panels.
Create a page and under the page settings you have access rules that can be quite elaborate within the UI. You can use a naked layout and then just had the forum entities as content to display and render the full node.
Second Look:
Take a look at the Drupal Module Flexiaccess. It looks like exactly what is needed and has a nice UI to manage the users that have access to the individual forum with out writing/maintaining custom stuff:

The Flexi Access module will provide a simple and flexible interface
to the ACL (Access Control List) module. It will let you set up and
mange ACLs naming individual users that are allowed access to a
particular node.
The module let you manage access to individual nodes. The
administrator may grant individual users the right to: View (read),
update (edit/write), and delete the node.
The main idea behind Flexi Access is to allow flexible per user access
control for nodes without the complexity (or features) of Organic
Lists, and without having to create a lot of (overlapping) roles.

I see you using Flag to set up the "subscription request" then a moderator looks at the flagged users with the Flag and if approves add em to the ACL with flexiaccess?


What is the proper format for the flag service calls? I'm running Drupal 7 with the Services 3 and the Flag Service modules installed. I'm having trouble trying to figure out how to format the the call in REST format.  Can someone provide a short example?

The flag service module (and probably the others you've listed in your comments) define their resources as actions, so you access them at a URL like:

http://server/[endpoint]/[module]/[action].json.

So for the flag action provided by the flag module that would be something like:

http://server/endpoint/flag/flag.json

This little snippet works well for me, based on a REST server with no authentication turned on and an endpoint with the path 'api':

$url = 'http://server-name/api/flag/flag.json';

$args = array(
  'flag_name' => 'bookmarks',
  'content_id' => 8,
  'action' => 'flag',
  'uid' => 1,

  // You wouldn't normally want this, the flag module provides it as an override
  // but it's a security risk. With proper authentication you can safely remove it.
  // I'm just using it for testing.
  'skip_permission_check' => 1
);

// Perform the curl
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($curl);

$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

if ($http_code == 200) {
  // Success
}

Answering the original question (What is the proper format for the flag service calls?), it's simply a matter of calling the correct URL and POSTing the required arguments to it, from whatever programming language you might be using.


Which module for relationships in my particular case? Possible Duplicate:
  Relation vs. References vs. Entity Reference for managing node-reference-type relationships in D7

I want to figure out which module (and, probably, strategy) will fit my needs best in such a situation.

I've built a site, there are a lot of piece's; each piece is either written or arranged by some person (or has both relations, composer and arranger); each piece can be a part of a collection (think of CD for performed piece's or book for scores in PDF).

Here piece, person, collection are types (post types, or node types in Drupal I believe); score, audio, video, text etc are taxonomies (in media tree). And each piece can have any or all media taxonomies assigned. Also there are genre taxonomies.

A person can be a conductor (if piece presents some performance by choir), soloist etc.

So, piece can be connected with person by a named "role".

Below are some links to demonstrate what I actually want to have (or something like that); the site made with WordPress (using posts-to-posts plugin).

However, I don't like what I have: that was the first my attempt to make a site, I am nor a programmer neither designer... I don't know what I am. Anyway, I don't like that site in terms of code maintainability (I guess that's my fault, not WP's), so I'd like to rewrite it; and I'd like to design new theme and have better ("overall php+mysql") performance.

So, now the question is: which module should I try for this --- Entity Reference or Relations? Or any other? Can I hope I can get better performance (php+mysql)?

Please, take a look (everything in Ukraine, but there are buttons to google-translate, SORRY):

here is Mykola Gobdych's page (conductor of Chamber Choir "Kyiv") --- below the photo there are links to other "views" (listen to pieces conducted by this person, listen to pieces performed by him, listen to his pieces --- either composed or arranged by --- etc)
some collection of piece's
a piece --- please, note, here are two performances... actually these are two piece's connected with "the same piece" relationship
listen to choir view

I really would like to try to do something like this with Drupal; however, I am very new to drupal. And I am not a programmer .)

So, please help; I will appreciate any helpful information or suggestion.

Thanks!

Both Entity Reference and Relation modules would do the work, but in your case I would suggest to go with Entity Reference module, since you don't have very complex relationships.


How to use view to display a list of nodes? My site have a restaurant node type and each restaurant node has multiple menu items. Each menu item has food name, price , discount, etc.

What I want to do is creating a view that shows a list of all menu item node list which belong to a specific restaurant node.

Can anyone tell me how can I do that?

Thanks!

Install

Menu Node API

  Manages relationships between node ids and menu items.

and Menu Node Views

  The Menu Node Views module provides Views integration for nodes
  assigned to the menu system.

Create a view something like this:

View of Content (nodes)

Contextual filter:

Add a contextual filter of Content: Nid

Fields:

Content: Title, and exclude from display.
Menu: Link title (The link text used for the menu item.)

Format: Unformatted list, with settings of Grouping field Nr.1 -> Content:title

That should do it.

This is not the only module solution available so research others as well.


Reviews Content Type with Rating Field We are looking to create a content type that will allow users to create reviews. Each review (node) when created it will be tagged with one taxonomy term.

For example, any user can write a review for Phone > LG > G3

One of the fields for the reviews content type will be RATING. The rating
will be five star and later will be used on a view to show an average score for the particular taxonomy term (product).

Based on the example ablove show an average score for LG G3 phone. Which will be shown in a view.

Should we use a list field (1,2,3,4,5 as options) for the RATING field? Or is better to wait until the Fivestar module is more mature? Haven't even used Fivestar but it seems that it will do what I am talking about. Or am I wrong?

Fivestar and maybe Rate seem like the modules for your problem.

But you can also use a list field like you mention. You seem to have the need to restrict the voting to the author of the Review node, while creating it (on Node Edit, not to all visitors on Node View).

But there aren't any ETA for Drupal 8 versions of those modules. Maybe you can help with that while working on your project? Although Fivestar has much more features than you seem to need, it's a more flexible solution and may be more future-proof.

It all depends on when you need it working, and how much you can invest in getting the D8 versions up and running.

If you're a developer or can sponsor one you can work on the D8 versions to get the superb usability for your users.

If not you can use the List field and some Views magic to build the basic vote and stats structure.


Can't get SQL query results I used a PHP code to show results of this query:

SELECT COUNT(*) FROM mytable

I want to get the number of rows in a specific table. This query works fine in phpMyAdmin, but it doesn't work when I place it in a template file.

I mean it doesn't return the number of rows.

Do you have any idea?

A template file should never contain code that executes a query; that should be done in a preprocess function, eventually.

The code to get the number of rows in a table is similar to the following one.

$count = db_result(db_query("SELECT COUNT(*) FROM {mytable}"));

The table name should always be put between curly brackets, which will be replaced with the prefix currently set for database tables.


jQuery ajax request breaks drupal behaviours In the Drupal commerce checkout I want to fill in the billing information automatically. I do that by attaching a javascript to that form and retrieving the information that is stored in the line item. That works great except for only one thing. The first time I click “continue on the next step” nothing happens and the page refreshes. But the second time the button does work and goes to the next pane.

It has the same strange behaviour when I load the page once, go to another page and go back. Then it works from the first time.

My javascript is rather basic and does work, but for some reason it breaks my form.

(function($) {
Drupal.behaviors.mymodule = {
    attach : function(context, settings) {

         var txtFullname = jQuery('input[id^=my_dynamic_id]');

        // do ajax request
        jQuery.ajax({
            type : "POST",
            url : 'http://example.com/retrieve_information',
            data : {
                'order' : settings.order_id
            },
            dataType : "json",
            success : function(data) {
                txtFullname.val(data.fullname);
            }
        });

    }
};
}(jQuery));

One thing I really have a hard time grasping (but then again I'm a Drupal beginner) is how a DOM operation can break the whole thing, especially when the only thing I'm doing is filling a simple textfield.

Is there a way in jQuery to trigger drupal to rebuild a form, because I have the gut feeling that this is the reason why it works the second time.

EDIT: It doesn't seem to have anything to do with jQuery as I have rewritten that part to use the Drupal ajax framework.

From the moment the billing information is filled in - i'm setting the values of the field  in hook_form - the submit button doesn't seem to work for the first time.

I presume you need to add that code with in document ready. Some thing like give

// Code that uses jQuery's $ can follow here.

(function($) {
Drupal.behaviors.mymodule = {
    attach : function(context, settings) {
      jQuery(document).ready(function($) {
         var txtFullname = jQuery('input[id^=my_dynamic_id]');

         // do ajax request
         jQuery.ajax({
            type : "POST",
            url : 'http://example.com/retrieve_information',
            data : {
                'order' : settings.order_id
            },
            dataType : "json",
            success : function(data) {
                txtFullname.val(data.fullname);
            }
        });
      });
    }
};
}(jQuery));


How does Drupal 7's SQL call for 'node' and retrieve an image? I have the following query shown in one of my views:

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created,
node.sticky AS node_sticky,
'node' AS field_data_field_featured_image_node_entity_type,
'node' AS field_data_body_node_entity_type,
'node' AS field_data_field_premium_content_node_entity_type,
'node' AS field_data_field_article_type_node_entity_type,
'node' AS field_data_field_video_upload_node_entity_type
    FROM
    {node} node
    INNER JOIN {field_data_field_sports_type} field_data_field_sports_type ON node.nid = field_data_field_sports_type.entity_id AND (field_data_field_sports_type.entity_type = 'node' AND field_data_field_sports_type.deleted = '0')
    WHERE (( (node.status = '1') AND (node.type IN  ('article')) AND (field_data_field_sports_type.field_sports_type_tid = '1884') ))
    ORDER BY node_sticky DESC, node_created DESC
    LIMIT 8 OFFSET 1

What does the 'node' in this query return, for instance when I'm calling:

...'node' AS field_data_field_featured_image_node_entity_type,

It seems to me that this should just return the string "node" but in the preview it's actually showing the image. When I do the SQL query in the console it's just returning the string 'node'. I'm confused because I don't see any JOIN statements on things like the field_featured_image table in this query, which I would have expected if the query actually was pulling the image.

How is the image getting shown via this query?

It's utilizing a loaded entity to fill in these placeholder columns. Per the views_handler_field_field::query() docs:

  By default, the only columns added to the query are entity_id and
  entity_type. This is because other needed data is fetched by
  entity_load(). Other columns are added only if they are used in
  groupings, or if 'add fields to query' is specifically set to TRUE in
  the field definition.

In the post-execute phase, during views_handler_field_field::post_execute(),  you can see where the field values are dropped in from the entity values.


Drupal Search API Placeholder && Front Page? I'm trying to get some placeholder text working for the Search API form, but have a different placeholder on the front page. Here's what I have so far which does work everywhere...

function THEME_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['search_api_views_fulltext'])) {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search Text here...');
  }
}

How can I get this working on only the front page, with a different placeholder text on all other pages? I've tried many things and totally stumped at the moment. Any help would be appreciated.

Check for drupal_is_front_page()

  Return value

  Boolean value: TRUE if the current page is the front page; FALSE if
  otherwise.

function THEME_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['search_api_views_fulltext']) && drupal_is_front_page()) {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search Text here...');
  }
}


how to apply single page checkout using drupal ubercart I am using Drupal6 with ubercart.I want to apply single page checkout instead of multi step checkout. When I checked the ubercart features it provide the one page checkout in features lint but  I am not getting idea how to use this feature.Is there  any module for it?

I have a package functionality in my site.There are three package silver,gold and standard.I want user can choose only one package at a time and user should be not able to add more package in cart if the package is already in cart and if user has already that package?

Please help waiting for the response.

Thanks in advance.

Yo cant make it single page. Mandatory steps are,

Add product to cart
Go to checkout page
Payment

You can combine the steps 3 by adding Shipping and billing address using Ubercart Checkout Tweaks module, which helps to

Assume billing and delivery addresses will be the same

  In many stores, orders are delivered to the billing address more times
  than not. Enabling this option in the checkout settings will default
  the "same address" checkbox at checkout, making the checkout page seem
  shorter and less intimidating.

For limit the products that added to cart you can use hook_add_to_cart

Parameters:
$nid - the node ID of the product
$qty - the quantity being added
$data - the data array, including attributes and model number adjustments


Drupal way to create a dynamic url as a content type field What would be the Drupal way to create a dynamic URL field on a content type.

Say I have a content type called 'dogs' and so I use that to catalog all the dogs I like on my site. Now I have created a view that lists in two columns 1) all the dogs that I like and 2) a link to search them on google. There are 100s so I would like to make a dynamic url field because I don't want to type in each google search to each record for the dog content type. So:

Title | Search Link

Maltese, http://google.com/#q=Maltese

Beagle, http://google.com/#q=Beagle

etc...

What's the best way to encode the field such that it says:

1) Get the title for this node (Maltese),
2) Append it to the string "http://google.com/#q="
3) Make this my field_dog_search_url

Is this something that can be done in the admin panel or is it better to use a hook. I'd rather use a hook than download and install yet another module just for this one instance, though I'm interested to know if there is a good module that handles this scenario.

You can do this through the UI. Select the "Rewrite Results" checkbox and "Output this field as a link". Then use replacement patterns to fill in the dynamic part of the URL.


How to disable Ubercart order mail notification? Everytime a customer places an order, the store owner gets an email with the order invoice. Where can I disable this? (the webshop is still in production)

Also, is it possible to set up a conditional to only send an e-mail when the customer has paid? (right now paypal payments works)

You can disable the Rule (Configuration -> Workflow -> Rule):
E-mail admin checkout notification.

About the second question, you can customize the Rule:
E-mail an order update notification
to email the store owner when the order changes status AND when the status is equal to "Payment received"

Hope this helps


Different style when listing nodes and displaying a single node I'm new at Drupal, coming from the PHP framework world, and I'm having some problems understanding the the template hierarchy in Drupal 7.

I've created a template called 'node--article.tpl.php' and can style my single article nodes. The problem is that this affects the front page as well. I want to style the node list different then when displaying single nodes. How can I do this?

Berdir's suggestion (coolest imho):

  you can even provide custom template suggestions based on the view mode. See for example drupal.org/node/223440 and bri-space.com/content/creating-drupal-template-suggestions

Also within node-article.tpl.php you can inspect $view_mode and decide what to do. You could either include the logic of both templates in the one file, or create different templates and include the appropriate one based on the value of $view_mode

You might also find Display suite interesting.


MENU_CALLBACK with parent tabs I have a module with a bunch of menu-items. Is it somehow possible to show the MENU_LOCAL_TASK's when a MENU_CALLBACK is called?
The structure basically is like this:

A normal menuitem in the user-menu
Some local tasks
'test/%user_uid_optional/test2' in this example would be an overview-Page with several links as defined in in the last item.

This all works great, except I want the local tasks to be visible when the user clicks on 'test/%user_uid_optional/test2/%test'. Since I don't have breadcrumbs that's the only easy way for the user to get back to the overview page.
Any idea?

function test_menu(){
  $items = array();
  $items['test/%user_uid_optional'] = array(
    'title' => 'test',
    'page callback' => 'test_whatever',
    'page arguments' => array(1),
    'access callback' => 'user_view_access',
    'access arguments' => array(1),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'user-menu',
  );

  $items['test/%user_uid_optional/test1'] = array(
    'title' => '...',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['test/%user_uid_optional/test2'] = array(
    'title' => 'test2',
    'page callback' => 'test_whatever_b',
    'page arguments' => array(1),
    'access callback' => 'user_view_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => -15,
  );
  $items['test/%user_uid_optional/test2/%test'] = array(
    'title' => '...',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_whatever_d', 1, 3),
    'access callback' => 'user_view_access',
    'access arguments' => array(1),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

never mind, menu_set_active_item('test/%user_uid_optional/test2') in test_whatever (last callback in example) seems to work.

Both item, 'test/%user_uid_optional' and 'test/%user_uid_optional/test2', are active and visible, and the drupal_get_form is executed, so who cares about beauty :)?


Using Rules How can I Remove a role from ANY user not just current user I have a use case for a project where a user of specific role has access to the site during specific dates. What I want to occur is- when the date passes the user loses his role and access to the site.

Currently, I have this rule working on Cron run, but the only option to me is to react on site:current-user. Is there a way to react on ANY user?

A possible approach to make this work, is to process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

load the VBO list of users that you want to be processed.
add a loop to perform a Rules Action, probably similar to the rule you already have in place, for each user contained in your Views results.

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".


Drupal 7 Forum with these features I want to setup a forum using Drupal 7 with these features:

Manage user roles and give or revoke access to forums or topic per user.
Create moderators where they can add,edit, delete members and forums,topics,posts
Be able to get email notifications for every action made in the forums
Be able to upload photos,docs etc

Could you tell which modules I need to make a forum like this?

Thanks in advance

Well you can use the forum module that comes with Drupal core or you can integrate a phpBB installation. Check this module: phpBBforum Integration module. phpBB 3 is the best open source bulletin board. It is fast, secure and has a lot of features and extensions (mods). All the features that you need above are supported by phpBB 3.


Passing Information to Drupal Referenced Entities before Render I have a content type called basic_page.  This content type has a field called field_elements which is an entity reference field.  The display settings for this field is set to 'Render Entity' - in other words, when a basic_page node is being rendered, it will also render the referenced entity.  All good - no problem.

My question is, I would like to pass run-time information (based on basic_page node) to the referenced entity that should be used in mytheme_preprocess_node when the referenced entity is being 'pre-processed`.

The problem is, by the time hook_preprocess_node is called for the referenced entity - I have no information of the basic_page node that 'contains' the referenced entity.

I was hoping that in hook_preprocess_field I could check if it is field_element and then set some value in the &$variables param I am getting in hook_preprocess_field that will persist to exist up to the point where hook_preprocess_node is called?

This works as designed. The referenced node can have multiple parents, but is only processed once and then cached.

A slighly different approach would be to use the context to check inside the referenced node, which parent node is displayed as page content.

Load the basic node with a route match in preprocess of the referenced node. See this question from today on blocks, which can be used in the node preprocess hook in the same way:

How to access field values from a custom block

You would also have to adjust the cache settings of the referenced node, see the comment in the linked answer.


How to find the source of inline css I'm kind of new to Drupal and I have to work on an already existing site using Drupal 8. In the main menu, when the links are hovered, they take the color of the background which is caused by some inline css tagged !important and I don't know how to find the file containing that line. Any idea on where to start?

Enable twig debugging to pin down the used template file(s) (if the output was added inside of a template). Search the templates before the !important output for that markup.
If you can't find it look at the preprocess functions used for those templates.


load recent nodes with node_load() How can I load recent nodes with node_load()?

I used the following code, but I can't edit the links because it creates a list where they are inside it. I want to load the node IDs, and then use node_load() to load each node.

$output = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), story, 0, 10));
print $output;

How is that possible?

Using only node_load() you cannot get a list of the most recent nodes, as node_load() returns a single node object for the node that matches some criteria; it's not a function that returns a list of nodes.

The faster, but a little inefficient, way to get a list of more recent nodes is to:

Get the list of node IDs associated with the most recent nodes
Call node_load() for each of the node IDs obtained from the first step

You could use code similar to the following one.

   $nodes = array();
   $result = db_query_range("SELECT n.nid FROM {node} n ORDER BY n.created DESC", array(), 0, $number_of_posts);

   while ($nid = db_result($result)) {
     $nodes[] = node_load($nid);
   }

After that code is executes, $nodes will contains the $number_of_poststh recent nodes.


Array value operators I'm trying to get the select field below only to show only when the value of the platform field is 4 or greater. Is it possible to nest an operator within the array statement? The code below works if I change >= to => 4 however that only works when the platform value is 4 and I need to to be any time it's 4 or greater.

$form['model'] = array(
  '#type' => 'select',
  '#title' => t('Select a Model'),
  '#options' => array(0 => t('- Select -')) + $options,
  '#default_value' => 0,
  '#states' => array(
    'visible' => array(':input[name=platform]' => array('value' >= 4)),
    'required' => array(':input[name=platform]' => array('value' >= 4)),
  ),
);

array('value' >= 4) is not the correct syntax to define an array containing the index value.

Basing on Fixed conditionals to allow OR and XOR constructions, you can use the following code.

$form['model'] = array(
  '#type' => 'select',
  '#title' => t('Select a Model'),
  '#options' => array(0 => t('- Select -')) + $options,
  '#default_value' => 0,
  '#states' => array(
    'visible' => array(
      array(
        array(':input[name=platform]' => array('value' => 4)),
        array(':input[name=platform]' => array('value' => 5)),
        array(':input[name=platform]' => array('value' => 6)),
        array(':input[name=platform]' => array('value' => 7)),
      ),
    ),
    'required' => array(
      array(
        array(':input[name=platform]' => array('value' => 4)),
        array(':input[name=platform]' => array('value' => 5)),
        array(':input[name=platform]' => array('value' => 6)),
        array(':input[name=platform]' => array('value' => 7)),
      ),
    ),
  ),
);

Using this code, the form field will be visible when the other form field value is one of the following values: 4, 5, 6, 7. It works with Drupal 7.14, or higher.


How to force redirect user to www.domain or http://domain in a nginx environment? I'm using drupal with nginx and i'm looking for a way to redirect users either to www.domain.tld or to http://domain.tld

Right now, if i log into the website using http://domain.tld, the website considers me as an anonymous user and i need to log in again when accessing www.domain.tld

I know drupal's .htaccess file manages this issue but it's ineffective with nginx

Thanks

I wouldn't think that Drupal would handle it any different that another setup, ie.. creating another entry for the non-www version with a redirect:

server {
  listen       80;
  server_name  example.com;
  return       301 http://www.example.com$request_uri;
}

server {
  listen       80;
  server_name  www.example.com;
}


what does the 'debug mode' on Services actually do? Each Services endpoint has an option for 'debug mode'.

What does this actually do?

The debug mode is essential to test if your service is working correctly through posting the logs. You can see the logs in admin/reports/dblog.  These logs shows you if you are sending the appropiate format,  if there is any error, etc.  The logs  allow  you to see the output of the transactions. I have attached a image with some samples of the logs messages. As far as I understand that it is the only use for the debug mode in the services 3 modules. If it is not or this answer was not accquire please post a better explanation.

As you say it uses watchdog, so you can see internally what it is happening with your service. I have included the service code if you like to see the function yourself git service

.


Why is file_managed not updated correctly? In a custom module (amap), I have a custom content entity (contract) created with Drupal Console.
There are standard CRUD functions on this entity.
One of the fields of the entity is a file field:

$fields['file1'] = BaseFieldDefinition::create('file')
  ->setLabel(t('Source file'))
  ->setDescription(t('Source file (may be modified)'))
  ->setSettings([
    'target_type' => 'file',
    'file_extensions' => 'doc docx odt pages',
    'uri_scheme' => 'private',
    'file_directory' => 'contracts',
  ])

When I create one contract adding a file (a.pages) to the entity, everything works as expected: a file with permanent status is added to file_managed table and appears in Files tab of content page:

and the corresponding record is added to file_usage table:

My first problem appears when I want to update the contract changing the file (to Contract.doc, for example):
file_usage table is correctly updated:

but file_managed table is not! The previous file (a.pages) is still there with permanent status.

The second problem is quite the same: when I delete the contract, file_usage table is correctly updated: there is no more record related to these files.
But file_managed table is not! The previous file (a.pages) is still there with permanent status (as in update mode).

My question is: is is normal?
Do I have to handle file_managed table myself?
Why is file_usage correctly updated and not file_managed?
I naively thought it was the case...

I changed file.settings config entry make_unused_managed_files_temporary to true and it seems to do the job.
Just hope there won't be any side effects...


alter/remove taxonomy term path if no related nodes I'm using taxonomy menu and nice menus to generate the page main menu. Not every term has related nodes, but the customer wants them all to be in the menu, but the "empty" terms not clickable. And when he creates nodes related to these terms, the terms should turn in to links.
Can I achieve that with hook_page_alter? Or is there a better hook to use.
I first tried hook_url_outbound_alter, and I was able to rewrite the path, but it's still a link, and I want to avoid that.
I know how to use rendered arrays, but this one is a bit tricky for me.

I would do that using hook_menu_link_alter() and Special Menu Items module, which provides special menu items like <nolink > and <separator>.


Is it possible to create an iCal stream from Open Atrium's calendar feature? If so, how? I'm getting mixed signals around whether or not its possible to create an iCal feed from the Open Atrium Calendar Feature.

When I try creating a new view or adding a feed to an existing view, I don't see the option for an iCal feed...just RSS :(

Can someone point me in the right direction?

Some background: http://drupal.org/node/348871

I ended up making the feed in a custom module using the iCalCreator library. I did like this approach because I was able to be very selective with the events to include in the feed which was a requirement and the iCalCreator library was VERY easy to work with :D


Results of autocomplete field in form depending on another field - Drupal 7 I have an autocomplete field in a Drupal form made with Form API. It works great, suggesting the data from a db_query.

However, I would like to alter this db_query depending on the selection made in another field of the form (a select field).

But I don't know how to do it, as I would need to change the db_query parameters on-the-fly (Javascript) but they are hard-coded in PHP!!

Is what I want possible at all? (it can be done in pure HTML + Javascript + AJAX PHP but I cannot imagine how to do it in Drupal).

Keep a wild card in your autcomplete menu path something like

function mymodulename_name_menu() {
  $items['example/autocomplete/%/%'] = array(
    'page callback' => '_mymodulename_autocomplete_callback',
    'page arguments' => array(2, 3),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
}

In your form

function mymodulename_my_form($form, &$form_state) {
// Your select field.
  $form['select_field'] = array(
    '#type' => 'select',
    '#options' => array(
      'option1' => 'Option1',
      'option2' => 'Option2',
    ),
    '#ajax' => array(
      'callback' => '_mymodulename_ajaxcallback',
      'wrapper' => 'replace_autocomplete_field',
    ),
  );
  // A container field
  $form['autocomplete_field_container'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $query_parameter = isset($form_state['values']['select_field']) ? $form_state['values']['select_field'] : 'default_value_to_start_with';
  // Your autocomplete field.
  $form['autocomplete_field_container']['autocomplete_field'] = array(
    '#title' => t('My autocomplete field.'),
    '#type' => 'textfield',
    '#autocomplete_path' => "example/autocomplete/$query_parameter",
  );
}

You Automcomplete menu callback

function _mymodulename_autocomplete_callback($query_parameter, $string) {
  // Use $query parameter to decide autocomplete field behavior.
}

Basically I am trying to update the autocomplete field by attaching '#ajax' behaviour to select field, and while updating the autocomplete field we will change the query parameter which db_query will use.


Is 'order completed' a safe way to assume that order is paid in full? I am working on a client's site. I have a requirement that when a user buys a product, a specific role should be assigned to the user.
For this, I have used 'business rules' module.
Business Rules
Reacts on event: After updating Entity
Target Entity Type: Order
Target Bundle: Default
Condition
Type: Data Comparison
Target Entity Type: Order
Target Bundle: Default
Field: state: State[state]
Data to compare: Current value
Operator: =
Value to compare: completed
Items to execute if condition succeed
Action: Add 'One year subscriber' role to user
My question is, Is this the correct way to identify that the product is purchased and order is paid in full?
That is, if order status is completed then is it safe to assume that the product is purchased and order is paid in full?

No. As with Commerce 1.x, we have a specific event in Commerce 2.x that is only triggered the first time an order is observed to be paid in full. It's defined in OrderEvents.php:
  /**
   * Name of the event fired after the order has been fully paid.
   *
   * Guaranteed to only fire once, when the order balance reaches zero.
   * Subsequent changes to the balance won't redispatch the event (e.g. in case
   * of a refund followed by an additional payment).
   *
   * Fired before the order is saved.
   *
   * @Event
   *
   * @see \Drupal\commerce_order\OrderInterface::getBalance()
   * @see \Drupal\commerce_order\Event\OrderEvent
   */
  const ORDER_PAID = 'commerce_order.order.paid';


How to create widget element with unlimited values? I have a widget for a field as shown below:

I would like to make the text field ('script_paths') an unlimited value so that the user can add as many as they like. Is there a way to do this? Maybe there is a property I add in my code below:

function mango_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  $field_name = $instance['field_name'];
  $required = $element['#required'];
  $item =& $items[$delta];
  $element += array(
    '#type' => 'fieldset',
  );

  $element['enabled'] = array(
    '#title' => t('Enabled'),
    '#type' => 'checkbox',
    '#default_value' => isset($item['enabled']) ? $item['enbled'] : '',
  );

  $element['script_paths'] = array(
    '#title' => t('Script Paths'),
    '#type' => 'textfield',
    '#default_value' => isset($item['script_paths']) ? $item['script_paths'] : '',
  );

  return $element;
}

I would think that there would be a property as well but I can't think of one for text fields. I know that you can use field collections though.

Edit: I was mistaken Field Collections will not work for custom forms, however This tutorial worked for me.


WSOD after installing Pressflow 6 I installed Pressflow on my Drupal 6 website by replacing core files. I only kept .htaccess, robots.txt and sites folder.

After that I got a lot of PHP errors, even after I change php.ini's error reporting.

So I checked Apache logs.

I had APC running on my site already and I noticed the following error happening frequently:

[apc-warning] Unable to allocate memory for pool.

It disappeared after I change APC memory to 16MB (it was 30MB) and restart Apache.

Although I can now load a few pages, I'm getting a white screen when trying to load home page and some other pages. Also, some regions of the page aren't showing up properly.

I tried clearing cache too.

Is there anything I'm missing?

My first step here would be try again. If you still get issues and there is nothing in the logs try increasing the memory limit.

Also there are some pressflow changes in htaccess, replace that roo.


How do I display serialized 'REST Export' with date format rather than timestamp? I am using csv_serialization contrib module to add csv encoding to the core Serialization output formats.

I have a view with a REST export display to allow the download of contact form 'message' entities, and as each contact form might have different fields I must return a (serialized) Entity rather than Fields (with the option to configure each field's display).

The resulting csv download lists created date as a unix timestamp and I need to format it as a human readable time and date, but as far as I can see the 'REST export' does not go through rendering so I cannot preprocess it in the same way I might with a different type of Views display.

Even with the rows being displayed as entities, you can have a hook_views_pre_render(&$views) invocation alter the entity field properties before they are used they are rendered out.

function MYMODULE_views_pre_render($view) {

  // Only alter my_view_machine_id view, rest_export display
  if ($view->id() == 'my_view_machine_id' &&
      $view->getDisplay()->definition['id'] == 'rest_export') {
    foreach ($view->result as $row) {
      if (isset($row->_entity->created)) {
        // Alter the entity created property to a readable ISO8601 date
        $row->_entity->created->setValue(date('c', $row->_entity->created->value));
      }
    }
  }
}

There might be a better part of Views rendering pipeline (e.g. REST views export has some templating system) to place this in, but it still renders out the altered serialized property.


Unable to load URL when drupal is installed on a server My drupal URL was loading normally until when I deleted two modules in the Windows server.Now after deleting the modules from the server the site is not loading.
I know that deleting a module does not result in the URL not loading it simply removes the module from the Module List.

I can't exactly find out what exactly is the reason behind this

[Update]I have checked under my Modules Menu and verified that both the modules are disabled and then un-installed from the modules list.

I know that deleting a module does not result in the URL not loading it simply removes the module from the Module List.

That's incorrect. If you delete a module without first disabling and uninstalling it, you could easily break the whole site. You're removing code that you've told the system exists when you installed the module, and it has no way to recover from that.

You should restore the deleted files temporarily, disable then uninstall the module properly with Drush, or through the UI, and only then should you delete the files.


Add JavaScript inside controller How to add JavaScript inside controller? I don't want to call build form. I can call css or js in src/Form/Form.php but I want to call css or js inside Controller src/Controller/Controller.php
This process I am using to call css and js in Form page

public function buildForm(array $form, FormStateInterface $form_state,$cid = NULL)
{

$form['#attached']['library'][] = 'cssjs/val_master';

}

Could anyone write some example to call css or js inside Controller

Thanks.

The same you can use in Controller also:

<?php

   namespace Drupal\cssjs\Controller;

   use Drupal\Core\Controller\ControllerBase;

   class CssJs extends ControllerBase{
     public function css_js(){
       $build['#attached']['library'][] = 'cssjs/val_master';
       return $build;
     }

   }


Get taxonomy fields on node.tpl.php I have a taxonomy attached to my nodes. The taxonomy has an extra image field attached to it. I can find the taxonomy title field at:

$content['field_news_outlet'][0]['#title']

but I can't seem to find the image field I attached to this taxonomy.

If I check with kpr() or dpm():

$term=taxonomy_term_load($tid);
$value=field_get_items('taxonomy_term',$term,'field_news_outlet_logo');

I can see the field name there but the image uri doesn't seem to appear anywhere in there. The only image uri I can find is the one for the site's logo.

I found the problem. I hardcoded $tid as 1 in my template file.


Status messages with AJAX I'm making an AJAX call in drupal 7 via the standard AJAX Framework. My  problem is that when a status message is set by the AJAX callback, it is simply lost (or displayed at the next reload of the page). How can I display the status messages right after the AJAX callback has finished running, without reloading the page? Is there a module for that?

You can render the status messages and send them as anohter AJAX command.

For example:

$commands = array();

// Add other commands

$commands[] = ajax_command_prepend('div#ajax-status-messages-wrapper', theme('status_messages'));

return array('#type' => 'ajax', '#commands' => $commands);

At least this is the way I solved this problem when I faced it.


Does node_delete() delete node_revision and comment as well? I want to delete the node_revisions and comments with node_delete().
Is this possible, or do I need to write custom code?

Little more context on this one since I had to answer this myself recently. The node.module code starts the delete operation by invoking all HOOK_node_delete functions it is aware of:

  foreach ($nodes as $nid => $node) {
    // Call the node-specific callback (if any):
    node_invoke($node, 'delete');
    module_invoke_all('node_delete', $node);
    module_invoke_all('entity_delete', $node, 'node');
    field_attach_delete('node', $node);

    // Remove this node from the search index if needed.
    // This code is implemented in node module rather than in search module,
    // because node module is implementing search module's API, not the other
    // way around.
    if (module_exists('search')) {
      search_reindex($nid, 'node');
    }
  }

One of which is the comment_node_delete() function in comment.module (clearing comments):

/**
 * Implements hook_node_delete().
 */
function comment_node_delete($node) {
  $cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol();
  comment_delete_multiple($cids);
  db_delete('node_comment_statistics')
    ->condition('nid', $node->nid)
    ->execute();
}

After it has finished with the modules that have references to these nodes, it then clears its own node tables for the NID:

  // Delete after calling hooks so that they can query node tables as needed.
  db_delete('node')
    ->condition('nid', $nids, 'IN')
    ->execute();
  db_delete('node_revision')
    ->condition('nid', $nids, 'IN')
    ->execute();
  db_delete('history')
    ->condition('nid', $nids, 'IN')
    ->execute();
  db_delete('node_access')
   ->condition('nid', $nids, 'IN')
   ->execute();

So - yes, node_delete clears both comments and revisions, as well as other node data and references.


Using taxonomy hierarchy in Views arguments I'm building a store with products organized with a hierarchal taxonomy. I'd like the paths for Views showing products to reflect the taxonomy hierarchy. For example, products/category-a/subcategory-a, products/category-b, etc. (In this case, products will only be a member of one category/term at a time, and terms will either have child terms or products associated with them, but not both - with the example paths above, products/category-a would list the child terms of the Category A term, but no products.)

I can build a view with a path like products/%, and that works just fine with products/category-b, but I can't figure out how to get that working with products/category-a/subcategory-a - it throws a 404. I've thought of implementing a Views alter hook to alter $args to only use the last argument, but the 404 is happening from a failure in menu_get_item() - before any Views code has a chance to run (and call alter hooks).

I can't think of any other pleasant ways to work around this, but surely I'm not the first one to want to try to implement a catalog like this… What's the most correct way to do it? (Ugh, I feel like such a site-builder n00b.)

2 ways to approach this:

Option 1: Custom module (preferred)

If you don't mind coding:

First, you'll need to create a view with a term contextual filter. It is also important to add "Has taxonomy term ID depth modifier" filter. This will ensure that if you pass the parent term ID, all items that are tagged in any of the parent's child terms will be included in the result.

Your custom module will have to do a few things to make this work:

Define menu items using the top-level terms. The menus will also accept child terms (sub-category) as optional parameters. In essence, you are defining menu items to be in this pattern - products/<category_id>/<[sub_category_id]>. Where sub_category_id is an optional parameter.
Define a menu callback which programmatically embeds the view. If the sub-category is not available, use the parent in generating the view. If the sub-category is available, use that instead.

Sample code:

<?php

/**
 * Implements hook_menu().
 */
function example_menu() {
  $items = array();

  // Define the menu for each top-level category. Each menu will have an
  // optional parameter that can contain the sub-category (a term under
  // the parent category).
  foreach (example_product_categories() as $tid => $term) {
    $items['catalog/'.$tid.'/%'] = array(
      'type' => MENU_CALLBACK,
      'page callback' => 'example_product_catalog_page',
      'access callback' => TRUE,
      'page arguments' => array($tid, 2),
    );
  }

  return $items;
}

/**
 * Page callback to generate the product catalog view.
 *
 * @param $parent
 *   The tid of a top-level product category.
 * @param $child
 *   A n-tier level of a product category.
 */
function example_product_catalog_page($parent, $child = NULL) {
  // @todo: Optional. Check that $child is a term under $parent.

  // If $child is defined, we use that to generate the product catalog.
  if ($child) {
    return views_embed_view('product_catalog', 'product_catalog_page', $child);
  }
  else {
    // If $child is not defined, we use the $parent to generate the product
    // catalog. This will also show all records tag in any of the parent's
    // child terms.
    return views_embed_view('product_catalog', 'product_catalog_page', $parent);
  }
}

/**
 * Returns an array of top-level product categories (terms) keyed by the tid.
 */
function example_product_categories() {
  $product_vocabulary = '<VOCABULARY_NAME>'; // The name of the vocabulary
                                             // that contains the categories.
  $categories = array();

  // Load the vocabulary using the name to get the vocabulary ID.
  // If you know the vocabulary ID, you can skip the loading of the vocabulary
  // object and proceed directly to the loading of the taxonomy tree.
  if ($vocabulary = taxonomy_vocabulary_machine_name_load($product_vocabulary)) {
    // Load a taxonomy tree with only the top-level terms.
    $categories = taxonomy_get_tree($vocabulary->vid, 0, 1);
  }

  return $categories;
}

Option 2: 2 Views

This would involve creating:

2 views, each with a page, or
1 view with 2 pages

The trick is to define 1 page that will accept 1 parameter only and another page that will accept 2 parameters. For the page that will accept 2 parameters, you can choose to ignore the 1st parameter or put in some validation (e.g. taxonomy validation).

Another option: Combination of modules

Although I haven't tried this, you might want to look at a combination of the following modules:

Taxonomy Menu
Pathauto
Views

I would imagine that this will take some custom codes particularly in creating a custom taxonomy path, which would involve implementing hook_taxonomy_menu_path(). The end-goal is to create a custom taxonomy path which would take the form of products/<parent-tid>/<[child-tid]> if the term has a parent or products/<parent-tid> if the term doesn't have a parent. The custom menus will then point to a custom view or views.


Work around to getting Backup and Migrate to work with Acquia Dev Cloud? Currently, when you host a site onto Acquia Dev Cloud, they disable the ability to install backup and migrate module due to it affecting their "server" setup. This proves to be a big nuisance when trying to create a quick backup of a site and to even make scheduled hourly backups. The suggest us to use the Acquia platform to do backups, but it's totally inefficient since it cannot schedule your own backup times. And doing this via drush is troublesome if you just want to do a quick backup because you wanted to make a change on a site just in case it breaks it.

How would one go around this problem of backing up a site with Acquia dev cloud?

The best is enable your access to the command line to their server.

For this you need to store your public ssh_key in your profile on their platform.

Then to find the exact server and username to connect do :

Sign in to the Acquia Cloud interface.
Select your application and
environment.
In the menu to the left, click Users and Keys, to see your exact command :

What follows is using drush ... but wait ... you can automate the use of drush : I explain.

Once logged, you can use drush from the command line, like this :

cd dev/livedev/docroot

drush ard

Since you have access to the command line, you can also use scp to transfer your backup.

By the way you won't have the possibility to access crontab -e there, however, you can write a script and execute from your computer to connect via ssh, do the backup, and get it using scp.

Once this script is written, you can use the cron from your computer to execute it every hour if you want.

That script would look like :

cd ~/dev/livedev/docroot
drush ard
cd drush-backups/archive-dump/
cd `ls -Art | tail -n 1`
mv `ls -Art | tail -n 1` ~/last_backup.tgz

You can store it remotely as ~/backup.sh locally in your cron you put

ssh -t -t yourlogin@youraddress '~/backup.sh && exit' && scp yourlogin@youraddress:~/last_backup.tgz /home/yourself

For an explanation of the -t -t, see https://serverfault.com/questions/224307/ssh-fails-to-execute-remote-command-when-run-from-cron-bash-script-works-from

If any other issue, with ssh from cron, please watch also : https://serverfault.com/questions/186448/crontab-to-run-bash-script-ssh-command-in-it-not-working

Another solution is to use the scheduled job from their interface, as explained there : https://docs.acquia.com/acquia-cloud/manage/cron

If any other problem please comment.


Dependent Selects to feed on taxonomies I'm trying to create a module that generates a block with Dependent Selects to feed on taxonomies, I mean the first would be the term father Select first level and then display a Select with the children of that term and so on, this is the code that I have so far:

/**
     * Implements hook_block_view().
     */
    function bloque_busqueda_block_view($delta = '') {
        switch($delta) {
            case 'bloque_busqueda' :
                $block['subject'] = t('Criterio de busqueda');
                $block['content'] = bloque_busqueda_block_content();
                return $block;
                break;
        }
    }

function bloque_busqueda_block_content() {
    return drupal_get_form('ajax_dependent_dropdown');
}

function ajax_dependent_dropdown($form, &$form_state) {
    $options_first = _ajax_get_first_options();
    $selected = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);

    $form["dropdown_first"] = array('#type' => 'select', '#title' => 'Seccion', '#options' => $options_first, '#ajax' => array('callback' => 'ajax_dependent_dropdown_first_callback', 'wrapper' => 'dropdown-second-replace', ), );

    $form["dropdown_next"] = array('#type' => 'select', '#title' => $options_first[$selected] . ' ' . t('Subseccion'), '#prefix' => '

    ', '#suffix' => '
', '#options' => _ajax_get_next_options($selected), );

    $form["submit"] = array('#type' => 'submit', '#value' => t('Buscar'), );

    return $form;
}

function ajax_dependent_dropdown_first_callback($form, $form_state) {
    return $form["dropdown_next"];
}

/**
 * Retorna el tid de la taxonomía actual.
 */
function current_tid() {
    $term = taxonomy_term_load(arg(2));
    return $term -> tid;
}

/**
 * Mide la profundidad de la taxonomía.
 */
function term_depth($tid) {
    $tid = db_query("SELECT tid FROM {taxonomy_term_hierarchy} WHERE parent = :parent", array(':parent' => $tid)) -> fetchField();
    if ($tid == 0) {
        return 1;
    } else {
        return 1 + term_depth($tid);
    }
}

function _ajax_get_first_options() {
    $terms = taxonomy_get_children(current_tid());
    foreach ($terms as $term) {
        $options[$term -> tid] = $term -> name;
    }
    return $options;
}

function _ajax_get_next_options($key = '') {
    $options = array();
    $tid = arg(2);
    $tree = taxonomy_get_tree($vid = 2, $tid);

    foreach ($tree as $term) {
        if ($term -> depth == 0) {
            $parent = $term -> tid;
        } else {
            if ($term -> depth > 1) {
                $options[$parent][$term -> tid] = str_repeat('-', $term -> depth) . ' ' . $term -> name;
            } else {
                $options[$parent][$term -> tid] = $term -> name;
            }
        }
    }

    if (isset($options[$key])) {
        return $options[$key];
    } else {
        return array();
    }

}

Thanks

you can use hierarchical_select module for this .


Why is the region in Drupal blank? I my .info file I have this:

regions[footermenu] = Footer Menu

The region--footer.tp.php has this:

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

I've placed a menu block in the "Footer Menu" (it shows up under structure->blocks). However, it's blank. If I place the block in region I know works the menu content is seen fine. Any idea why the region wouldn't see the block?

as your question doesn't have any proper explanation, people most likely cant help you. but I can guess that what you are doing wrong is that you make a region--footer.tpL.php file (you missed the L in the end), you also need to render it on the page you want it there to be, so practically it wont show you anything since its not rendering at all.

my suggestion is forget about region--footer.tpl.php and add

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

right into your page.tpl.php or any other theme hooks you might want it there.

by the way a very rookie mistake is that you already done everything right but after editing your .info file you forgot to clear the cache in admin/config/settings/development/performance


How to show Users and Nodes in a single view? Using the Flag module I have created a bookmark flag for User and Node entities. Working so far so good, but I cannot create a view that displays both Node and User entities in one view.

How do I do this without having to dump views and hand-create the page in PHP?

One option is to add a user view as a footer to the node view. The footer can be configured to inherit the same contextual filters as the main view.

You can't get joint paging or joint filtering using this approach but it works in some scenarios.

I've also hacked into the views hooks before and manually created a db join but that is a nightmare to maintain so I wouldn't recommend it.


Why are there .htaccess and php files in ./sites/default/php/twig Just wondering, it may be related to cache settings, but why are there lots of php and .htaccess files in the public:// dir?

The PHP files are compiled Twig templates and the .htaccess file protects them from public access. You can switch off the caching of compiled twig templates by setting this service parameter to FALSE.

# Twig cache:
#
# By default, Twig templates will be compiled and stored in the filesystem
# to increase performance. Disabling the Twig cache will recompile the
# templates from source each time they are used. In most cases the
# auto_reload setting above should be enabled rather than disabling the
# Twig cache.
#
# Not recommended in production environments
# @default true
cache: true

You find this in sites/default/default.services.yml, which you have to rename to sites/default/services.yml to activate it.


Where has module-specified HOOK_preprocess_page gone in D8? I'm making a quick module whilst playing with D8, which I want to preprocess Stylus into CSS. The obvious choice for me, coming from D7, would be to use hook_preprocess_page, but it seems to have been removed from D8, or at least only in themes and not modules.

So just to reiterate, I have my module stylus, my file stylus.module and the function stylus_preprocess_page(&$variables), but no dice.

What would be the best D8 alternative?

This hook has not been removed, there are still preprocess hooks for modules:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/function/hook_preprocess_HOOK/8.2.x


How to customize a content type css? I have a pdf sharing site with a content type which called PDF. This content type has many fileds (such as author, description, rating, etc). These fields display in simple rows but I want to change either their form and css. for example I want to show Rating number much bigger (and in other color) on the top of each post. what can I do?
Am I able to define new css classes for these fields?

create a new template file and add any classes you want. Here's a good introduction to D7 templates.

your template should be named like this: node--node_type.tpl.php. In your case, I think it should be node--pdf.tpl.php. You can use node.tpl.php as a starting point


hook_menu does not match I have a module where I try to catch an url to use a specific function.

function my_module_menu(){
    $items['beneficiaire/commande'] = array(
        'page callback' => 'test_view',
    );
    return $items;
}

function test_view(){
    var_dump('test_view');
    exit();
}

Unfortunately, when I call beneficiaire/commande nothing append.
I know Drupal go through this hook because when I do

function my_module_menu(){
    die('poc');
}

I see 'poc'.

Your callback function is wrong:

function my_module_menu(){
  $items['beneficiaire/commande'] = array(
    'page callback' => 'commande_view',
  );
  return $items;
}

function commande_view(){
  var_dump('test_view');
  exit();
}


link being printed from "nowhere" I'm a bit stumped. For some reason Drupal prints some extra links and I can't find where are they generated.

This is what I see in my output:

The arrows point to the extra ocurrences of

The template code for this page is like this:

<?php if ($logo): ?>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

<?php endif; ?>

<?php if ($site_slogan): ?><?php print $site_slogan; ?><?php endif; ?>

 <?php if ($page['search_box']): ?>

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

 <?php endif; ?>
 <?php if (theme_get_setting('social_icons')): ?>

<a href="http://www.twitter.com/<?php echo theme_get_setting('twitter_username'); ?>" target="_blank" rel="me"><img src="<?php global $base_url; echo $base_url.'/'.$directory; ?>/images/twitter.png" alt="twitter"/>

<a href="http://www.facebook.com/<?php echo theme_get_setting('facebook_username'); ?>" target="_blank" rel="me"><img src="<?php global $base_url; echo $base_url.'/'.$directory; ?>/images/facebook.png" alt="facebook"/>

<a href="<?php print $front_page . ($language->prefix ? '/' : ''); ?>rss.xml"><img src="<?php global $base_url; echo $base_url.'/'.$directory; ?>/images/rss.png" alt="RSS"/>

<?php endif; ?>

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

    <?php
    $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
    print drupal_render($main_menu_tree);
    ?>

I've been looking all over the place, and can't find WHERE is that coming from. Searching in site's source code I only found 1 instance of a similar looking URL, inside a Module I disabled and deleted from the host; and still the same thing.

The links appear both before the main menu starts building, and after. Several times for the first menu item, but never again. And it only happens with anonymous users, never with logged in users...

Any pointers in where should I be looking to fix this?

Thanks a lot in advance.

Edit:

I found that the problem lies in this piece of code:

ÁREA DE CLIENTES <img height="14" width="14" src="/sites/default/files/pictures/clipart/key.png"

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

If I remove the #link-clientes
; the ghost links stop appearing later on. Still don't understand why.

It can't be that hard to understand. There's a syntax error:

ÁREA DE CLIENTES <img height="14" width="14" src="/sites/default/files/pictures/clipart/key.png"

 tag is not closed. That's breaking your whole page HTML structure/well formedness.


How to add a path filter to views 3 in Drupal 7? This doesn't have to do with contextual filters but is it possible to add a filter criterion to views so that it filters the aliased path to a node?

Content:Path is available as a display field but why not as a filter too? Kind of similar question to this

Try the Views URL alias module.

The 'Views URL alias' module allows Views to be filtered by path aliases.
This module is useful if your website uses heirachical paths. It allows you to filter and sort a view by URL aliases. When combined with the Views bulk operation (VBO) module you can apply operations to a specific section of your website based on a URL alias.

Note that Currently, only node aliases are supported.


Where Can I find the output of the debug() function displayed? I have written debug() in a php file in my local Drupal project. I am trying to see the output. How do I do that?

The output should be logged to the Drupal watchdog (admin/reports/dblog). If you're debugging a variable that is an array or object, don't forget to pass TRUE as the third parameter (ref).

Although the code in question may be in a function cached by Drupal, so sometimes you need to flush the cache to trigger that code to be re-run.

Personally, I prefer using the dpm() function from the devel module for debugging. If using an account with admin permissions, it displays arrays/objects in a way that is easier to inspect.


Setting current node url as default value for "Link" field I have a content type with a field type Link. I would like to set default text and url for the field. Under:

  Structure » Content types » MY CONTENT TYPE » Manage fields

I tried entering # and [current-page:url:absolute]. Both of them were not accepted and the below are the respective error messages:

The value [current-page:url:absolute] provided for MY FIELD NAME is not a valid URL.
The value # provided for MY FIELD NAME is not a valid URL.

What is the right way to enter the current node URL as a default value into a Link type field?

You need to use module field default token to work global as well local token in field value. You can use your previous token i.e. [current-page:url:absolute].


Is there a way to avoid implementing a logic in the view template? Some where I have read that we should use views template xxxxx.tpl.php file to not implement complex logic. I want to show a search results message to the user. The message is not made of mere row count but it has little bit of logic depending on what options he has selected.

I have implemented this logic in my view mymodule-view-grid--apartments--listing-row-filtered.tpltemplate.tpl.

I don't think this is complicated logic that's why I went on and implemented this logic but a question always bothers me is that where should I implement this logic if at all I have to implement it outside and how to pass this variable to this template.

<?php

  $view = views_get_current_view();
  $rowCount = $view->total_rows;

  isset($view->exposed_input['field_location_tid'])?$ltid = $view->exposed_input['field_location_tid']:$ltid = 'All';

  //force to all if landing directly
  $city = taxonomy_term_load($view->exposed_input['field_city_tr_tid'])->name;
  $locationName = $ltid == 'All'?'':' in ' . taxonomy_term_load($view->exposed_input['field_location_tid'])->name;
  //
  $resultText = "Properties in $city: Your search criteria matched $rowCount properties$locationName";

?>

<?php print($resultText);?>

... and rest of the template follows unchanged

Templates are for displaying content, not building it, so you're right to want to avoid this.

Drupal allows you to preprocess any theme function to add variables. I guess in your case it would be something like

function MYTHEME_preprocess_views_view_grid(&$vars) {
  if ($vars['view']->name == 'some_view') {
    $vars['foo'] = markup_building_function();
  }
}

Then back in the template file you can output that var like so:

<?php echo $foo; ?>


Drupal-to-Drupal data migration Taxonomy issues I'm wondering if there is something special I need to do within the UI when using Drupal-to-Drupal data migration to actually get taxonomy terms to port over with all my nodes. I get an error that reads

  No matching taxonomy term found for source value '144' in vocabulary Topics.

I've created first level terms and ported over each term correctly, but what is the special thing I need to do to actually map the terms with the nodes? I've mapped the TID and yet it still doesn't work. Is there something special Im missing?

Well, this is a couple years' old now, but thank you doodirock for tickling my memory on this. You need to configure that field's source_type value to 'tid'. I'm doing so in code, but I believe that you can set this in the UI. The code you need is this:

$this->addFieldMapping('field_news_categories:source_type')
  ->defaultValue('tid');

In my UI view, this row appears like this:

Where 'tid' is the value input.

As the documentation points out:

  source_type: If the option value is 'tid', then the incoming value is assumed to be a valid term ID in the destination Drupal instance. Otherwise, it is assumed to be a term name (the default behavior). Note that you'll want to set this to 'tid' if the mapping has a source migration (the sourceMigration() method is used on the mapping).


Migrate users from Drupal 5 to Drupal 7 I want to migrate users from a Drupal 5 site to a Drupal 7 site.

I have enabled the Migrate and Drupal-to-Drupal data migration modules.

I know I have to make a custom module extending the built in classes of migrate_d2d module to migrate users. The problem is:- which migrate class do I extend while making the custom class?

And am I right in thinking that that code for creating the custom class should be placed in user.inc file?

I am migrating content from one database (legacy) to another database (active).

Upgrade from Drupal 5 to 6, then from 6 to 7. That's it. No further modules or writing your own code is needed, users and content will migrate just fine. You only need Migrate and other modules if you have some special stuff on your site, like Organic groups. CCK version 7 will be needed in most cases, but that's all in the documentation.

Here's the documentation, follow carefully:

From 5 to 6: https://drupal.org/documentation/upgrade/5/6

From 6 to 7: https://drupal.org/documentation/upgrade


How to do something BEFORE a view is updated via ajax submit button? I have a view with exposed filters and Ajax activated.
I would like to validate my exposed filters values before my view is updated by the submit button.
The following code works without Ajax, but when I activate this functionalitty it doesn't validate!

jQuery('FORM ID').submit(function () {
  jQuery('FILTER TEXTFIELD').val(MY VALIDATION);
  return true;
});

How can i capture the ajax execution and validate my values BEFORE the ajax call?

You have to capture the mousedown event on the submit / apply button, prevent submission using e.preventDefault(), validate and if everything is fine submit the form using $('#form-id').submit()

Update:

Here is a fully tested and working code:

(function ($) {
    Drupal.behaviors.ValidateAjaxForm = {
        attach : function (context, settings) {

            var $form = $("form#views-exposed-form-list", context); // ajax form selector, or better specify by class name
            var $submitButton = $('#edit-submit-list', $form); // ajax submit button selector, or better specify by class name

            // Use off to remove any existing submit handler
            $form
            .off('submit')
            .on('submit', function (e) {
                e.preventDefault();
                var $form = $(this);

                var valid = false;

                // Run some validation on $form object.
                // check conditions here and if all is fine declare valid = true

                // If vaild, trigger event on button
                if (valid) {
                    $form[0].submit();
                }

            });
        }
    };
}
    (jQuery));


Drupal 7 Organic Groups, Drupal Commerce and Paypal I have a Drupal 7 site, with OG and commerce installed.  I have an og content type populated with content.  Everything is working as expected.  I found this link on Drupalcommerce:  https://drupalcommerce.org/blog/10809/selling-organic-groups-using-drupal-commerce and it is very close to what I'm after.  However, I don't want to charge the users for access to the group. I want to charge per group.  Just like meetup.com does.

In short, I would like for a user to:

Enter a group name Username and email
They are taken to Paypal to complete transaction
Paypal signals the transaction is complete
The group and user are created.

Any tutorial or guidance is appreciated.
Many thanks
Chris

Please check out Commerce Node Checkout Module It gives you a basic Pay to Pubish workflow, which is exactly what you are try achieve.

As the project page says the module helps you

  Integrate with Commerce in order to allow you to charge users to
  create nodes.


Drupal Upgrade module: SQL table prefixes and upgrading from Drupal 7 to Drupal 8 When I ought to do an upgrade to my site from Drupal 7 to Drupal 8, and I go to localhost/site/upgrade in my D8 site, I am being asked about table prefixes in my site's SQL DB... Indeed, all the tables in my DB include prefixes, but I didn't understand from the explanation at Drupal upgrade module's description if it is a must to bring them into this advanced options field in the module.

Maybe a Drupal dev could shed some light here about this...

It means that if you were to install another Drupal, 7 or 8 on the same database (zentech0_Benia), using prefix will prevent causing confusion/collision.

Ex:

having two tables named accesslog is confusing.

while having site1_acesslog, site2_acesslog you know which accesslog belongs to which site.

In conclusion, if you don't plan on installing another Drupal 7 or 8 in zentech0_Benia, (having 2 websites in the same database) then you don't need table prefixes.


How to create a chart for tracking Product stock over some period of time using Ubercart? Does anybody know about a good solution for tracking Product stock in a certain timespan?

It is nice to see the stock numbers of products, but I find quite handy to see product performance over time.

My Questions: Is there any module for this? Or is it more appropriate to create such Product stock tracking using views?

Edit: Maybe it's possible to record some "Product stock"-field into some database?

You should try views charts for creating graph

  About the Project

  Provides a "charts" style output for Views module so you can render
  result-set not just as text (list, tabular) but as pie-chart,
  bar-chart, scatter-plot etc.

  DC DrupalCon '09 Presentation

  http://vimeo.com/5306364

  Dependencies

  Views Charts and Graphs Suggested modules

  For Drupal 6 you will need the Views GroupBy: if you want to chart
  anything actually useful. Views 3 for Drupal 7 has grouping built in.
  Documentation

  Views Charts has basic usage instructions available as Advanced Help
  pages. Please install and enable it to see the available help.


Custom access method for a Page Manager page I've created a page using Page Manager, at the route /project/(node}/attendance.
I need to add a custom access check on it, comparing information about the current user with the node to see if they should have access.
I have added a route subscriber, but when I loop through the route collection, my route does not appear. I have read that this is because pages added through the page manager are they themselves nodes.
Is there a way to add a custom access method to a Page Manager route?

So, what I ended up doing is extending the Page Manager PageAccessCheck service:
services:
  custom_route_access.page_access_check:
    class: Drupal\custom_route_access\Entity\PageAccessCheck
    tags:
      - { name: access_check, applies_to: _page_access }

And then:
<?php

namespace Drupal\custom_route_access\Entity;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityAccessCheck;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\Routing\Route;

/**
 * We're overriding the page access checks so that we can add our own.
 * Mimics the generic entity access but with a custom key to prevent collisions.
 */
class PageAccessCheck extends EntityAccessCheck {

  /**
   * {@inheritdoc}
   */
  public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {

    // Backup the original requirements.
    $original_requirements = $route->getRequirements();

    // Replace it with our entity access value and run the parent access check.
    $route->setRequirement('_entity_access', $route->getRequirement('_page_access'));
    if($route->getPath() === '/project/{node}/take_attendance'){
      return self::takeAttendanceAccess($account);
    }
    $access = parent::access($route, $route_match, $account);

    // Restore the original requirements.
    $route->setRequirements($original_requirements);

    return $access;
  }

  /**
   * Check that user is admin or staff OR has an active team leader registration.
   */
  private static function takeAttendanceAccess($account){

    // ... my custom access check code
  }

}


Form state redirects do not respect https on some forms I added custom redirects, for example on the user login form:

function my_module_user_login_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form_state->setRedirect('view.my_custom_view.page_1');
}

This is working well even with https on my test server: the user will be redirected after login to the view page with https, let's say https://my-domain.de/my-view-page

On another server the same is not working: on this server the domain is only reachable via https - not via http. This means calling http://my-domain.de will lead to a server error only using https://my-domain.de the project will be displayed. Now when I login I will be redirected to http://my-domain.de/my-view-page (without https) which leads to this server error.

I am sucessfully logged in: when I enter https://my-domain.de/my-view-page manually I can reach this know. When logout (I did not any changes here) the same appears: After logout the user gets redirected to http://my-domain.de.

Can somebody give me a hint what can be the problem on the second server?

Best,
Tobias

On another server the same is not working: on this server the domain
  is only reachable via https - not via http

Perhaps a redirect to force HTTPS was not set up on your other server.

see Enabling HTTP Secure (HTTPS). You can do this by altering the VirtualHost definitions on your 2nd server:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect "/" "https://www.example.com/"
</VirtualHost>

or alternatively you can do it in the .htaccess file by adding:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


What is the template file name for a bean block? My block is called "hero", on the front-end the class is block-bean-hero, what is the proper template file name for this block?

As I can infer from the class name, your module name is "bean", so the template name should be block--bean--hero.tpl.php. For more information you can check the Template (theme hook) suggestions documentation.


What does #optional mean for a "details" form element? The node edit form contains the following form element.

  $form['revision_information'] = array(
    '#type' => 'details',
    '#group' => 'advanced',
    '#title' => t('Revision information'),
    // Open by default when "Create new revision" is checked.
    '#open' => $node->isNewRevision(),
    '#attributes' => array(
      'class' => array('node-form-revision-information'),
    ),
    '#attached' => array(
      'library' => array('node/drupal.node'),
    ),
    '#weight' => 20,
    '#optional' => TRUE,
  );

What does the #optional property mean for it?

I looked at both the Details and the VerticalTabs classes, but neither of them seems to handle that property.

What does setting #optional to TRUE do?

This is handled in the render element Details:

Details.php:

  public static function preRenderDetails($element) {
    ...
    // Do not render optional details elements if there are no children.
    if (isset($element['#parents'])) {
      $group = implode('][', $element['#parents']);
      if (!empty($element['#optional']) && !Element::getVisibleChildren($element['#groups'][$group])) {
        $element['#printed'] = TRUE;
      }
    }
    return $element;
  }

If #optional is TRUE and there are no visible children, then the element is not rendered.


How do I use Drush 8 site aliases in Drush 9? In Drush 8, my site aliases are loaded correctly from ~/.drush/mysite.aliases.drushrc.php.

E.g.

$aliases['dev'] = array(
  'root' => '/var/www/html/mysite.dev/docroot',
  'uri' => 'mysite.prod.acquia-sites.com',
  'remote-host' => 'mysite.ssh.acquia-sites.com',
  'remote-user' => 'mysite.dev',
  'path-aliases' => array(
    '%drush-script' => 'drush' . $drush_major_version,
  ),
);

However these aliases aren't loaded in Drush 9.

$ drush site-alias
{  }

How I should define site aliases in Drush 9? Is there any migration process?

Aliases are now provided in YAML files. According to the example aliases file for Drush 9:

  To convert legacy alias (*.aliases.drushrc.php) to yml, run the site:alias-convert command.

So running the command:

drush site:alias-convert

should do the trick.


Flickr-like responsive photo gallery for Drupal 8 Is there a good Drupal 8 module to display a responsive photo gallery, a la Flickr (example: https://www.flickr.com/photos/tags/red)?

I tried Views Photo Grid but it's not working for me, when I go to create a view type of "Photo grid" per the instructions that option is not listed.

If there's no Drupal 8 module, what'd be the easiest way to go about creating this feature? Creating a photo content type, then a view? Is there a way to pull in the viewport size then dynamically size the thumbnails accordingly?

Thanks.

Drupal 8 has built-in Picture module with support of responsive images.
So you need to create new content type "Photo" with image field.
Add some photos of new content type.
Create new view of type "Grid List" and add Photo image field to display.
Or create new view of type "Unformatted", add Photo image field to display, then remove default field formatting, modify CSS.


programmatically get bundles from field collection? Say I have the machine name of a given field collection. How can I programmatically get the names of the node bundles where one would find this field collection? This would be the same information you see on the admin/structure/field-collections page.

What about:

$bundle = db_query("SELECT bundle, entity_type FROM field_config_instance WHERE field_name = :field_name", array(':field_name' -> $field_name))->fetchAll();

If you know the enity_type then you can use field_info_instances().


Views : Make a block related to a page (with flag/addthis/privatemsg as fields in this block) It's difficult to explain but i'll try to do my best.

I have a basic views (Page) with all my fields displaying.
My purpose is to take some of this fields to display them in a block(on the left sidebar)

This fields i want to display in a block are:

Flag: bookmarks
AddThis: Toolbox
Private msg (send message to the author)

I follow all the screemcast "Taming the beast" (from nodeone.se) especially part 24 when Johan Falk explain how to make a block with a related content to a page (without using page manager)

When i go to my article my url is like that: /fiches-produits-services/100  (100=>[nid])

I follow this step when i create my block:

Add my fields etc.
Add contextual filter : content: nid
click on it, go to WHEN THE FILTER VALUE IS NOT AVAILABLE
Click on Provide default value
Select Content ID from url

But after that nothing, the block isn't here.
When i click on Display all results for the specified field on the same section, the block appears but with all the flags, the privatemsg and socials icons from all my article.

It's not the bahavior i want, i would like to have just the flag related to the article, just the link from private messages related to the article etc.

I don't know if i missed something. In the screemcast he did that with content(article) related with another content (basic page), maybe we can't do that with flag, addThis or privatemsg because it's not really a content (But i don't really know i'm new).

So if someone can help me to understand that, i'll be very grateful.

I found a way this week to get the good behavior.

i understood my mistake! My url was like that www.example.com/my-product/2 (made with pathauto)

When i selected content ID from URL my block was empty because he couldn't retrieve the good argument from the url (because my node id was in second position)
But when i go to www.example.com/node/2 it works fine

To resolve my problem i select raw value from URL  instead of content ID from URL (because with that option we can select which argument we want to retrieve --that was the second for me because of my custom url)

In summary i follow this step :

Add contextual filter : content: nid
click on it, go to WHEN THE FILTER VALUE IS NOT AVAILABLE
Click on Provide default value
Select raw value from URL
Select the argument you want to retrieve from the url (path component)
I check Specify validation criteria
Validator : content
Filter value format : node id
Action to take if filter value does not validate : no result

It was a stupid mistake :) but i learn some stuff :)


How to insert line breaks in views global custom text field? My view renders plaint text output - no HTML allowed. I want to format my fields with \n line breaks. How do I do that?

With HTML not allowed, you don't allow line breaks.  You would need a <br /> element to render a line break, otherwise it will be one big paragraph
If you have it set up the way you want, and all you want to do is add the /n to the output of a field:

Add a Global Custom Text field (make sure it is below the field you want to add the /n to).
Insert the token under Replacement Patterns for the applicable field.
In the text box, add the /n after the token.


Clearing Twig cache only? We have this large website where we would have to deploy html changes in Twig quite often. I'm looking for a solution to clear the Twig cache ONLY. So we do not have to do a general cache rebuild, which consumes a lot of CPU each time. drush cc render does not work, twig html still cached. Any suggestions?

Invalidate the twig cache first, like this:

drush php-eval "\Drupal::service('twig')->invalidate();"
drush cc render


Master Detail webform or connecting/linking two webforms I just got a project request that went from simple to complex.

the original project was just to collect basic user info, the complexity comes in, now they want the user to provide detail on his/her car or cars.  So one submission could have 1 2, 5 detail entries.

is it possible to do a master/detail setup using drupal webforms?  i need to create a webform that will have a general info in the top, ex: fname, lastname, age, location, range

there will also be a detail section of their webform that will contain: car type, partID, quantity, type, past requests for example.

Is there away to connect two webforms as there could be several details related to one submission?

Example:
Were I doing this in straight php, i would have a master/detail tables
one take holding the fname, lfname, age, location range date
one table holding car type, partID, quantity, type, past requests
the later table would have a key to connect the items to the first table, easy

How can I accomplish this, or can I accomplish this using webform?

I did a search on connect, link, combine webforms, but not getting anything concrete back, so want to see if i need to rethink the entire process before continuing down the rabbit hole.

Any ideas, advice suggestions would be greatly appreciated.

Thank you in advance.

For those who come along with a similar issue - my solution here was to use the entityform and fieldcollection modues.  the fieldcollection module allow you to attached a group of sub fields to the entityfield, then you can add more of the subfields as needed.  Querying and views were also fairly easy to set up.


How do I transfer nodes categorized with one taxonomy term to another? Im on d7. I have a lot of nodes on my site that are all categorized with one of eight terms of my "category" vocabulary. I have been doing a theme redesign that calls for me to make a new taxonomy vocabulary that these node will be categorized in called "sections". I need a way to make all current nodes with "categories/term-1" to also have "sections/term-1", "categories/term-2" to have "sections/term-2", and so on. I was thinking I could do this with rules, but that would be a per node basis and I need this to update ALL current nodes. Any suggestions?
Thanks.

You can use hook_update_N() to update multiple nodes at once with a single run of update.php. Inside it you can load all the nodes that you need to modify using node_load(), and after you are done changing the taxonomies programatically, call node_save().


Create custom and unlimited Node list per user Lets suppose I have a content type (movie) and I have all movies of Hollywood, I want let  each user can create it's own lists,as example I want to create "My Top 10 movie","My 12 Hot movie","Top fincher","Top Kubric" etc,I know I can do it by Nodequeue module,it is good for users that know how work to Drupal Nodequeues ( they should first create a nodequeue add machine Name and its machine name should be unique(select machine name that the other users not create it before) then surf the site and find desire movies and go to nodequeue tab and add that node to it`s nodequeue (really is it too hard for popular users)),But my problem is my user of website is popular web surfers ( not Drupal expert).

Also I can create a content type ( movie lists)  with entity reference,each user can create a node of movie lists, add desire movies by auto complete field and save it.

I want to know is there another way to create  lists of nodes per user and each user could have serveral lists and can control add/remove nodes to their lists ?

You can have a look on these modules

Flag
Flag Lists

Using Flag module users can save nodes in to their bucket
and Flag lists module will make those lists as like folder structure.


Theme path in javascript I need to use my theme path in a jQuery script for a D8 theme I'm building. I know this is available as drupalSettings.path.baseURL (followed by the path to my theme) but how do you make this variable available to javascript? Lots of D7 info out there, not much D8.

You can attach the drupalSettings in any form / build / preprocess etc.

Something like :

function HOOK_preprocess_html(&$variables) {
 $variables['#attached']['drupalSettings']['path']['themeUrl'] = \Drupal::theme()->getActiveTheme()->getPath();
}


Render published content or comments on new created content using a link I was looking without luck for a way to be able to make a link or button with the functionality of making a new content showing some content or comment already posted above, something like the Retweet option to be more clear.
Is there a module or combination of modules to achieve this?
Edit:
Now after an answer I know it is easily rendered with a reference field, all I need now is a way to create a link that will auto fill the reference field. That way the user clicking the link never see the field, my idea is that that field is not visible in 'Manage form display'.
Edit 2:
Prepopulate module do the desired link. If I disable the field on 'Manage form display' it stop working. So I used Popup field group
As I told in the comments, this module makes a Popup with only desired fields, but instead doing it, no Popup is opened and the form is rendered with all the fields except the ones supposed to appear on the Popup, so I use the module to get my reference field only on the Popup group and that way this field disappear on create or edit content. Because I am solving this taking advantage of a module that did not do correctly what it should do, if someone thinks that this solution is not a safe way to do it let me know other way to achieve it.

You can use an Entity Reference field.  In Drupal, most of the "content" that you see, including nodes and comments, are entities.
Entities can be linked to each other with an Entity Reference field.
Here's a tutorial video.
One challenge when working with Entity Reference is that each field can only reference one type of entity-- so you can have an Entity Reference field for nodes, or for comments, but not both at the same time; to have both, you need two fields.
Out of the box, Entity Reference can be configured to select the content by autocomplete or by a select list, which can be the output of a view you have customized, so it's quite flexible.


Private data in node format The Overall Plan

I'm creating a staff "portal" area for a non-profit. In the future I want to migrate the current static front-end website to Drupal, so I thought it would make sense to develop this portal area as a custom module into the back-end Drupal administration.

About the custom module

The non-profit provides a Child Sponsorship program, allowing supporters to pay a monthly fee which pays the school fees for children in East Africa. So the idea of the portal will be that it will reduce the administration of staff by holding the sponsorship database online. The database is split into two: children who are sponsored and children on the waiting list.  So I want to produce a module where each child is effectively a node. The node will contain sensitive information such as DOB, Address, School Exam Results etc and so isn't AT ALL for public viewing.

However, that when a child is added to the waiting list, a short bio will feed into the front-end website allowing them to be sponsored. This is one reason for trying to build it into Drupal from the beginning. In the future, it is also planned that when a user goes onto the front-end website, chooses a child to sponsor, they will be made a 'user' in Drupal, and given the ability to view certain information about their child such as a school report.

Questions

Is it conventional use of Drupal to build a module specifically for internal use where primarily the data is not for the public or front-end website? Is it an appropriate use?

To me it makes sense that each child functions as a node of content type 'child', however I'm worried about making them actual nodes.....as I said the data is private, and Drupal currently sets node public at URL node/{nid} What is the best solution moving forward with creating this database within Drupal? Could I make an equivalent 'node' style format?

Drupal only sets node/nid as public when you give anonymous users permission to "access content". Additionally, you can use modules like http://drupal.org/project/content_access to specify what roles can access specific content types. Lastly, you can use http://drupal.org/project/field_permissions to specify what roles have access to specific fields on your nodes.

To answer your other questions, I don't think you need to write any custom modules to cover these needs and using Drupal to provide content only to privileged members is a very common use case.


Render scald atom with image style, without new scald context? We have a field or type "Atom Reference", that references scald images.
I want to render these in a node display, using an image style.
For this we need a formatter that will render the scald atom with this image style.

The way we currently do this:

Create the image style.
Create a scald context, and configure it to use a "transcoder" based on this image style.
Use the scald context as a formatter in "manage display" for the node view mode.

This means, we need to create a separate scald context per image style.

What I would prefer is to have just one formatter, and then choose the image style in the formatter settings. Maybe with a "flexible" scald context, and then let the formatter alter this context programmatically.

Does something like this exist?

The module Scald style contexts aims to provide a context for an image style, I think it potentially addresses some of the additional configuration.