2

I want to publish some content in a day, not all of unpublish content at once.

for example I have 20 unpublish content and i want to publish 2 random content in a day at 13:00.

How can I resolve this?

2

If you aren't concerned with the "random content" portion of your question you could use the scheduler module to accomplish the task - https://drupal.org/project/scheduler which would allow you to set specific times during the day when you wanted content to be published.

If you do want it to be randomized though, you're going to need to use rules - https://drupal.org/project/rules and VBO - https://drupal.org/project/views_bulk_operations.

(I'm assuming Drupal 7)

  1. Create a view.
  2. Under Fields add a "Bulk Operations: Content" field. Set the number of entities to your desired number (in this case 2.) Set it to publish content, Enqueue the operation instead of executing it directly.
  3. Under Filter Criteria set it to "Content: Published (No)."
  4. Under Sort Criteria set it to "Global: Random (asc)"
  5. Under Pager set to "Display a specified number of items" and choose the number of desired items (in this case 2)
  6. Save your view.
  7. Now to go Rules configuration.
  8. If you are only running cron once every 24 hours (at 13:00) you could trigger this on cron run, otherwise you'll need to set up some additional steps. Assuming the 24 hour cron, set your rule to execute when "Cron maintenance tasks are performed".
  9. Under actions click add action then select "Load a list of entity objects from a VBO View." Select the view you just created from the value dropdown. Click save.
  10. Then under actions click add loop. Default variable name at the bottom should be "list_item." Click save.
  11. Now click the add action button horizontal to the loop you just created. Select node publish content. For the "data selector" field use list_item from the loop above. Click save.
  12. Run cron to test.

2 random pieces of content should publish.

  • thanks for your answer. it is very usefull and works. but my cron is not working, when i run cron, i have this error= "Fatal error: Call to undefined function ara() in /home/zyazilim/public_html/spor/modules/php/php.module(80) : eval()'d code on line 4". i added "function ara()" to my template.php. how can i fix this error to run cron? – user2175535 Jan 5 '14 at 1:28
  • Comment out the function in your template.php and see if cron can run. There may be a syntax error somewhere in the function. – pokermoneyclips Jan 7 '14 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.