Filtering Drupal vocabularies - drupal

Apologies if this is a duplication - I'm a total newbie to Drupal and there's a fair chance I've read the answer to my question and just not realized it.
I have a simple vocabulary with 2 tiers. Structure is:
Canton
-Town
So looks like:
Vaud
-Vevey
-Montreux
Valais
-Sion
-Brig
I am trying to build a form with 2 separate fields as drop down list, 1 for canton and 1 for town, populated from the vocabulary where list 1 has only the cantons (1st tier of vocabulary) and 2nd only has towns (2nd tier) with the relationship to the canton.
Cant figure out how to do it ... after 2 days searching coming here for help.
Any guidance much appreciated

Related

Woocommerce reuse values in variable products

I hope someone can help me with this :)
I will be selling a product that has 10 variables, but all the choices need to be the same for all, how can I add and reuse the values once instead of copying and pasting values 10 times?
What I will be selling is a 10 meal bulk package and each meal needs the
same choice values.
Picture of what I'm trying to achieve here
Thanks for any help in advance :) Scott
I have 3 different products, 5 meals, 7 meals and 10 meals in which the customer can choose their own meals, the attribute values will also be changing weekly. which at the moment I am pasting in new values 22 times in the edit product.
If I delete and duplicate the product I lose the URL
When I go to Products > attributes still the same making 10 attributes like meal 1, meal 2, meal 3 etc I can't duplicate them and have to do it all manually up to 40 times with new values.
[Picture Front end here]
(https://dl.dropboxusercontent.com/u/61411490/Screen%20Shot%202015-09-17%20at%2009.33.32.png).
This is a very late answer, but I have encountered the same issue and my solution might be of interest to the next person who happens on this question.
I am using WP All Import and the Woocommerce extension (both free, but variable products require a license) to maintain product details in excel. Updating data on the website is as easy as uploading a new CSV. Keeping data in sync in an excel file, with references, formulas, etc. becomes much easier, and you can often completely factor out duplicate data.
Instead of using Woocommerce's variable products, I created each version as a simple product and linked between them.

R: Clustering customers based on similar product interests for an event

I have a dataset with a list of customers and their product preferences. Basically, it is a simple CSV with a column called "CUSTOMER" and 5 other columns called "PRODUCT_WANTED_A", "PRODUCT_WANTED_B" and so on.
I asked these customers if they were interested to know more about a particular product, and answers could be simply YES or NO (1 or 0 in the dataset). The dataset can be downloaded here. Obviously, there will be customers with many different interests, based on the mix of their YES or NO in these 5 columns.
My goal is to understand which customers are similar to others in such interests. This will help me manage an agenda of product presentations and, in each meeting, I would like to understand the best grouping for it. I started with a hierarchical plot like this:
customer_list <- read.csv("customers_products_wanted.csv", sep=",", header = TRUE)
customer.hclust <- hclust(dist(customers_list))
plot(customer.hclust, customer_list$CUSTOMER)
library(rect.hclust)
rect.clust(customer.hplot,5)
This is the plot I got, asking for 5 clusters:
Tried the same, but with 10 clusters:
Question 1: I know it's always hard to tell, but looking at the charts and dataset, what would be your 'cut' to group customers? 5? 10?
I was reviewing the results, and in the same group, I had CUSTOMER112 with 1,0,1,0,1 as their preferences together with CUSTOMER 110 (1,1,1,1,1), CUSTOMER106 (1,1,1,1,0) and so on. The "distance" can be right, but in a given group I have customers with some relevant differences in their preferences.
Question 2: I don't know if it's a case of total ignorance about clustering, the code I used or even the dataset. Based on your experience, what would be your approach for the best clustering in this case?
Any comments will be highly appreciated. As you see, I did some efforts, but still in doubt.
Thanks a lot!
Ricardo
All answers were important, but #Ben video recommendation and #Samuel Tan advice on breaking the customers into grids, I found a good way to handle it.
The video gave me a lot of insights about "noisy" variables in hierarchical clustering, and the grid recommendation helped me think on what the data is really trying to tell me.
That said, a basic data cleaning process eliminated all customers with no interests in any products (this is obvious, but I didn't pay attention to it at first). Then, I ignored customers with a specific interest (single product). It was done because these customers wouldn't need to attend the workshop series I'm planning (they just want to listen about one product).
Evaluating all the others, interested in more than one product, I realized the product mix could point me to a better classification. From there, I grouped customers into 3 clusters: integration opportunities (2 or 3 products), convergence opportunities (4 products) and transformation opportunities (all products).
Now it's clear to me which customers I should focus on for my workshops, and plan my post-workshop sales campaigns leveraging materials that target each customer group (integration, convergence, transformation).
Thanks for all the advices!
Ricardo

Trying to build a 'random text' WordPress plugin. No idea where to start

Here’s what I’ve done in a spreadsheet:
I’ve assigned people to one or more categories (ie. male, female, tall, short)
I’ve assigned weights to these people (ie. 200 lbs, 120 lbs, 300 lbs)
I’ve assigned names to these people (ie. John, Jane, Bill)
Here’s what I need to do in a plugin:
Find some way to get my data into it (maybe through an admin interface, or via my spreadsheet)
Filter results by one or more categories (ie. only male; only tall + female, etc)
From those filtered results, pull 2 or 3 people (as many as I can fit) whose combined weights equal X or less
Display the names of those 2 or 3 people as a list to front-end users
At the press of a button, randomly generate another 2 or 3 person team
I don’t mind getting my hands dirty, but I don't know where to begin. If you guys could give me any advice, best practices, code to get me started, or names of plugins that already do this, etc, I’d really appreciate it.
Also, if I’m biting off too much for a complete noob, feel free to let me know. Because if it comes down to it, I’ll just create the teams manually and throw them into a random text plugin, or something.
This depends heavily on what format it's in presently. If it's in a spreadsheet, you can import it pretty easily by saving as a CSV and processing it with fgetscsv
Assuming this is going into MySQL (as most WP plugins do), this is just a SQL query (ie WHERE wp_custom_person_record_weight > 100 AND wp_custom_person_record_name != 'Bill'
Same as #2 but with a JOIN and a SUM and a WHERE query against that sum.
This is the same SQL query, if you call it through mysqli_query you'll get an array back that you can output on the page
Random records can be gleaned a number of ways, either by going through a limit of X,2 where X is a randomly generated number between 0 and the # of records or through MySQL itself (although that is not recommended for performance reasons).

Drupal: Split View by Date

I'm currently working on a small website with a list of course dates.
I am using Drupal 7 with views for this. I made a view where all courses are sorted by dates, which is a quite long list, so I'm thinking of adding a headline, with the month between the headlines.
For example, now my list looks like this:
Course 1
Course 2
Course 3
...
And I want to have:
January
Course 3
Course 4
February
Course 3
Course 4
I'm quite new to drupal and so I hope anybody can help me. Thanks!
I found a solution which is working. In drupal views you can group your fields by a field value. I found a screencast which explains how to do it:
http://www.youtube.com/watch?v=Cp2SPiwA2Qg

Model complex permissions based on groups

I am trying to model the following permissions in Plone and would like to know the best approach I should take:
Group 1 - Senior members
Group 2 - members
Group 3 - Senior members
Group 2 - members
All the members in the groups shouldn't be able to view any content item associated with them.
Senior members should be able to view and amend content items within their sub groups but should not be able to view each others content items - these content items all have a user_id field to indicate who the content belongs.
Members in sub groups should not be able to view content associated with senior members nor each others content items.
Thank You
I think you're going to get the same answers here as you got with your mailing list post: http://plone.293351.n2.nabble.com/Implementing-bespoke-access-control-levels-in-Plone-td6986879.html
You'll need to write your own local role adapter using http://pypi.python.org/pypi/borg.localrole. Perhaps take a look at http://pypi.python.org/pypi/borg.project as well and the article introducing it: http://www.martinaspeli.net/articles/developing-with-plone-3-borg.localrole-and
Try using collective.subscribable sections. I haven't fully tested it yet, but it seems to be doing the job for me. I went the borg.localrole route, and it was a major pain, and I was never happy with my solution.

Resources