I'm working with Symfony2.
I have to get links to the previous and next articles of loaded article.
for instance.:
I have 3 post (1, 2 and 3).
When I'm in Article 2 need to show links to articles 1 and 3 (previous and next)
Any idea how to do it efficiently?
thanks in advance
well the best hint i can give is to query for a date.
So the next article is the first one that is older and the prev article is the first one that is newer
Related
Increase pagination index to start from 1 instead of 0.
So in URL instead of ?page=0 it should be ?page=1 for first page and then ?page=2 so on..
This question is documented in Drupal core issue #1818040. It looks like the patch from comment #15 needs to be re-rolled for the latest minor release. If you are working with a limited code line and have control over your content, that might be enough. However, in the long term it looks like a fix needs to be found for the fact that this implementation is going to break URLs on existing sites and potentially interfere with other contributed modules.
Side note: I would like to go ahead and call to your attention an article written by Edsger W. Dijkstra's titled "Why numbering should start at zero". When you say "such and such event is happening in three days" you do not mean the day after tomorrow but rather the day after the day after tomorrow. Your count does not begin with today but rather tomorrow, as today is when you begin counting (today = 0).
TL;DR: In the case of your book, the first page you encounter is the beginning, and you cannot begin counting before you have begun reading.
Let's assume there is a blog and you would like to list the most liked or shared posts for today, the last 7 days and the last 30 days.
The solution for today is rather easy:
-mostSharedPostsForToday
-2018-10-08
-$postId
-numberOfShares
Then the query would observe mostSharedPostsForToday/2018-10-08 for today's most shared posts ordered by child numberOfShares.
But how to structure the data for the most shared posts in the past n days?
One solution I can think of is to write a cloud function that populates the node mostSharedPostsForThePastNDays on a daily basis. But it seems cumbersome to me. Isn't there a more efficient way?
Edit: As pointed out in the comments of the 1st answer pagination should be supported to save traffic.
I recomand you to use another approach. In stead of using the date as your node, remove that node and add a TIMESTAMP for each post like this:
-mostSharedPostsForToday
-$postId
- TIMESTAMP: 2018-10-08
- numberOfShares: 10
To know how many shared you have in a single day, you need to use the following code:
rootRef.child("mostSharedPostsForToday").child(postId).orderByChild("TIMESTAMP").equalsTo("2018-10-08");
And if you want an interval please use the following code:
rootRef.child("mostSharedPostsForToday").child(postId).orderByChild("TIMESTAMP").startAt("2018-10-08").endAt("2018-10-15");
Hope it helps.
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
How do I discount ALL products in the cart based on the quantity of any and/or all products purchased? For example, when the user buys a totale of 10 products (any combination of products), the products are discounted of $5.00 each.
I've looked at the following modules. I don't believe they are the solution. (Some are just problematic.)
uc_bulk_discount
uc_discounts_alt
uc_pricelist
(Answered in the comments. Converted to community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
#Sam Healey wrote:
just wanted to asked if you've seen http://drupal.org/project/uc_discounts_alt
The OP wrote:
Sam, Yes, I did see uc_discouts feature list, but thanks for the cattle-prod, because on second reading its worth trying ... the feature listing touches on the requirement and as feature lists go, sometimes there's something missing. So, thanks, I'll give that a shot, i.e. install the mod and look closer.
SOLVED! - Thank you, Sam! After a review of Sam's suggestion regarding uc_discounts_alt, the requirement has been met. The module provides the discounting functionality required by the client.
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 :/