P
P
Pavel2015-06-29 17:33:56
Drupal
Pavel, 2015-06-29 17:33:56

Select every 5th node programmatically in Drupal 7?

Hello. Actually the question is in the title, you need to select every 5th node on the page. JS naturally does not roll. Implementation is required on the backend. I can't find a hook. Tell me - who can implement?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
holyorb2, 2015-07-01
@pantey

Write your own function:
- load from the database according to the node table, all NIDs of the desired type of material in the amount of 50 pieces (if there are 10 nodes on the page, then we take 5 times more)
- select only 5 nodes in a cycle
Then there are options:
1. We generate content ourselves (for example, to display on a page or in a block) https://api.drupal.org/api/drupal/modules!node!nod... + https://api.drupal.org/api/drupal/modules! node!nod...
2. Passing a list of NIDs somewhere, for example, to views

D
Drupby, 2015-06-29
@drupby

If the nodes are output by a view, then you may need to insert some code before or after the output of the 5th node, then drup.by/snippets/vstavka-koda-vnutr-predstavleniya , but if you need to somehow wrap every fifth node (add markup) , then this is done in the template
. But in general, the question is not specified at all, therefore such an abstract answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question