Should PhD students be goal or opportunity driven? PhD students usually go through a specific topic in depth for several years: understand it and contribute to its literature. Some topics are multidiscipline by nature. Thus, while studying, students may find nice contribution opportunities in not-directly related areas to their research problem. 

is it better to be goal-driven (i.e focus on the thesis problem alone) or opportunity-driven (i.e spend your PhD in different problems you encounter in this topic)?
Although naturally the details of the landscape differ from subject to subject, here is my picture from mathematics:

In addition to the obvious point that one should "both" stay focused on a long-term project and be alert to incidental opportunities, I would claim that the best kind of thesis projects (and projects in general) are those that help create incidental opportunities along the way to a worthwhile large-scale goal.

(This in addition to "educational" benefits of well-conceived projects.)

The obvious hazard is to get distracted from a reliable, long-term project by too-speculative "cooler" possibilities one encounters along the way. The hazards here are like "... but don't quit your day job" as advice to aspiring rock stars, etc.