Drupal 6 Views: Constraining fields which are not the "primary" node - drupal

I'm making a custom list of nodes and their comments. I'd like to be able to both constrain the number of nodes (easy: Items per page refers to nodes in this case) but also constrain the number of comments displayed per node (e.g. the 5 most recent):
Node number one
Comment 1-3
Comment 1-2
Comment 1-1
Node number two
Comment 2-7
Comment 2-6
Comment 2-5
Comment 2-4
Comment 2-3
Node number three
So Node number one has three comments. Fine. And Node number three has no comments. Also fine. But Node number two has seven comments; but I only want to show the most recent five.
Is there any way of doing this in Views? It's easy enough to make a view which has the comments in and an argument to provide the node id, were it possible to include such a view inside another view, for example.
I'm brand new to Drupal, so apologies if it's an obvious question. I've googled it, but it's hard to know if you're googling the right thing when you've just started.
Any suggestions appreciated!
Rob

according to the views developper here http://drupal.org/node/353872
is almost impossible to do in just one query, and as such is something Views can't support.
however, these modules might be interesting for you:
Views Group By or Views Attach and might be a step closer to the solution.

I can't think of an easy way to do this in views alone. You might need to do a combination of views and a little custom code to get the final result :/

Related

How do I link between items in Qualtrics?

I have a block of 7 items in Qualtrics. Right now, I have it set up so it displays the first item to everyone, and then presents a random item from the next 5, and then presents the last item to everyone. The last item asks respondents to summarize what they read (which was one of the 5 random ones).
I want them to be able to go re-read the item in case they weren't paying close enough attention.
Some ways of doing this might be:
Include a back button (but I'd want this to be the only place where they could go back), and I don't think it'd work anyway since I have randomization.
Include a link? (e.g. "To re-read the passage click here" and then something would pop up?) I don't know if there is a way to do this.
Include the last item on the same page as the randomized ones. It automatically broke them into separate pages - is there a way to include them in the same page?
If anyone knows how to do any of these, or has another suggestion, please help :)
Put the 5 random items and the last item in the same block, then under block options choose Question Randomization. Use Advanced Randomization to show 1 of the 5 random items, and show 2 items per page.

Lucene Interlacing Search Results

There may be posts like this on here but I'm not sure what to call this type of sorting method so searches haven't really yielded anything very useful. Mostly I've seen things about boosting terms but I don't think that will help in this case unless I can make the boosts have diminishing returns (and even that may have an issue at scale). Links to those would be appreciated if they exist.
I'm creating a module for a blog page in Sitecore that will display a small number of related blog posts. These blog posts should be based on the authors of the blog. This is relatively easy to do when there is one author however the requirements given have made this difficult when there are multiple. The requirements state that when there is more than one author, the blogs that show should alternate between each author's most recent post with no duplicates. An example would be this:
In this scenario a blog post's order of posting is represented by the letter (post A was posted before post B).
Blog post Y has 3 authors whose names are Jack, Jill and Jim.
Jack has posted another blog post X.
Jill has another post that is more recent than Y called Z as well as older posts N (done with Jim) and M.
Jim has posted blog posts N (done with Jill), O and L.
The order that these posts should show up based on the scenario is as follows:
X N O M L
Note that when Jim's first post is supposed to be used N is not used because it is already in our result list when Jill's post was shown.
It's looks like I'm potentially going to need to do a query per author in order to deal with this or query for posts filtering on the authors, sorting by date and then manually dealing with the resulting list. The first way results in multiple queries though and the second way potentially can involve iterating over the entire index.
I also thought I could do the following:
Store an int field called related author sort. Make that equal to the number of blogs written by the author with a post date before the current blog (may take a while to process that). Do an inverted sort on that.
The point of inverting the number would be so that field wouldn't need to be updated whenever a new blog was added. That falls apart though since there are multiple authors so I would need multiple author sort values.
Note: doing it this way will end up bringing authors with more blogs to the top rather than what I want.

How can I determine the "correct" number of steps in a questionnaire where branching is used?

I have a potential maths / formula / algorithm question which I would like help on.
I've written a questionnaire application in ASP.Net that takes people through a series of pages. I've introduced conditional processing, or branching, so that some pages can be skipped dependent on an answer, e.g. if you're over a certain age, you will skip the page that has Teen Music Choice and go straight to the Golden Oldies page.
I wish to display how far along the questionnaire someone is (as a percentage). Let's say I have 10 pages to go through and my first answer takes me straight to page 9. Technically, I'm now 90% of the way through the questionnaire, but the user can think of themselves as being on page 2 of 3: the start page (with the branching question), page 9, then the end page (page 10).
How can I show that I'm on 66% and not 90% when I'm on page 9 of 10?
For further information, each Page can have a number of questions on that can have one or more conditions on them that will send the user to another page. By default, the next page will be the next one in the collection, but that can be over-ridden (e.g. entire sets of pages can be skipped).
Any thoughts? :-s
Simple answer is you can't. From what you have said you won't know until you have reached the end how many pages the user is going to see so you can't actually display an accurate result.
What you could do to get a better result as in your example is to assume they are going through all the remaining pages. In this case you would on any page have:
Number of pages gone through so far including current (visited_pages)
Number of the current page (page_position)
Total number of pages (total_pages)
The maximum number of pages is now:
max_pages = total_pages - page_position + visited_pages
You can think of total_pages-page_position as being the number of pages left to visit which makes the max_pages quite intuitive.
So in the 10 page example you gave visited_pages = 2 (page 1 and page 9), page_position = 9 and total_pages = 10.
so max_pages = 10-9+2 = 3.
then to work out the distance through you just do
progress = visited_pages/max_pages*100
One thing to note is that if you were to go to pages 1,2,3,4,9,10 then your progress would be 10%,20%,30%,40%,83%,100% so you would still get a strange jump that may confuse people. This is pretty much inevitable though.
Logically unless the user's question graph is predetermined, you can not predetermine their percentage complete.
That being said.
What you can do is build a full graph of the users expected path based on what information you know: what questions they have completed, and what questions they have to take, and simply calculate a percentage.
This will probably involve a data structure such as a linked list to calculate where they have been, and what the user has left to complete, this implementation is up to you.
The major caveat here is you have to accept that if the users question graph changes, so will their percent completed. Theoretically they could display 90% and then it changes and they will display 50%.

Website Layout Statistics

I have a client who has suggested laying out a long list of categories in a custom order. The order is to be decided by them based on product items they sell the most etc.
I tend to disagree and feel that people browsing the internet prefer to search lists of categories that are in alphabetical order or sorted by something they can take reference of such as a date.
I would like to know others thoughts on this and it would be appreciated if anyone could point me in the direction of any open source surveys that have been taken in this area.
Thanks
Ben
What a silly stance to take regarding a simple customer request. Allow for both orderings, and other ones too. There is no survey that will demonstrate that the client is wrong as they are - by definition - correct.
Code that allows for different orderings has greater utility anyway, and real user data will be able to show them which - if either - should be the default.

How to display only taxonomy terms with nodes associated to in Views 2?

I've created a view with a set filters exposed (to show filtering options in the page). And one of those filters is a select field with all the taxonomy terms of a vocabulary.
That's ok, it's showing now. But I want to only show the taxonomy terms that have at least one node associated to it. To avoid empty results if selects an empty term.
Anyone knows how to do that?
Thanks.
Solution in views 3 (which may work in views 2)
Set a relationship for the view to join the terms to the nodes (in views 3 this is 'Taxonomy term: Content with term')
Then in the options tick 'Require this relationship' (this excludes terms without any nodes)
This may produce duplicates, in views 3 you open up Query settings, and tick Distinct (this will omit duplicates)
This would be a great feature for Views to have and you should submit a feature request to the maintainers for it. Unfortunately you can't do this with the existing Views code.
\What you could do, though, is see how Views constructs a filter control in its own source code, and implement that function yourself and add in an extra check to see if there are any posts with that term or not, and not display that term if there aren't any.
This is a simpler way. Hope it helps.
Add a relationship, filter for terms and choose "Taxonomy term: Representative node". Check the "require this relationship" and thats it. Optionally tick "Query settings > Distinct" in case of duplicate terms.
Based on http://www.waldbeek.com/blog/view-taxonomy-term-and-hide-empty-terms
With views 3 this gets very simple using aggregation! I'm posting this replay because I spent a lot of time discovering it. Everything is very well explained in this screencast: http://dev.nodeone.se/en/the-aggregation-setting-the-emmajane-episode

Resources