Mounting an outdoor ceiling fan in a pergola?
I am with you, the first one is much more attractive.
The jct box must be mounted on a cross member, 2x4?, and then they added boards with a hole for the jct box.
It would be just same as if it was in ceiling and drywall except the box would need to be set at the correct depth for the thickness of the wood.