Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today’s WorldView newsletter.

The 1997 film “Wag the Dog” depicts a U.S. president who faces a sex scandal weeks ahead of an election. In response, he fabricates a war to divert attention. It was a work of fiction influenced by reality: The writers reportedly credited the U.S. invasion of Grenada in 1983, which came shortly after a deadly attack on the U.S. Marine barracks in Beirut, as inspiration.

Shortly after the film was released, though, it seemed as though life was also imitating art. Just a month later, facing its own sex scandal, the Clinton administration bombed suspected terrorist facilities in Sudan and Afghanistan.

Neither Clinton nor the filmmakers were the first people to realize calling out the troops is a good way to boost a president’s appeal. Now President Trump appears to be following along as well.

With less than a week before midterm elections, Trump is embroiled in a vast array of scandals, facing recent mass killings that appear linked to his rhetoric and trying to stave off a “blue wave” of Democratic victories. In response, he has turned a far-off group of migrants into a national emergency — and used all the theater of war that he can to do so.

On Monday, the president ordered 5,200 service members to the U.S.-Mexico border to “harden” the border against a caravan of Central American migrants, creating a military spectacle and playing up the essentially nonexistent danger. The head of U.S. Northern Command, which controls troops in North America, said Tuesday that even more troops will soon be sent out.

As Today’s WorldView noted last week, Trump had previously suggested — without any evidence, as he later admitted — that there were “unknown Middle Easterners” in the caravan, suggesting that the migrants were a grave terrorism risk. He has repeatedly called the distant group an “invasion,” a term other Republicans and right-wing media have eagerly adopted.

The president further upped the ante on Tuesday, telling Axios’s Johnathan Swan that he plans to end birthright citizenship — the constitutional provision that says anyone born in the United States is automatically a U.S. citizen.

Trump claimed that he could do so with an executive order. In reality, because birthright citizenship is part of the Constitution, a new law or a new constitutional amendment would be needed. Legal opinion is not on Trump’s side, either. “Legal experts have debated for years how to interpret the citizenship clause of the Constitution’s 14th Amendment, but most agree with the long-held practice of granting citizenship to those born on U.S. soil,” The Post’s Robert Barnes wrote.

But reality may not be the point. In his interview with Axios, Trump also said — falsely — that the United States is the only country with laws that allow birthright citizenship. In fact, at least 30 other countries have similar policies in place.

Neither of Trump’s actions have any modern precedent. Ending birthright citizenship has been the province of bit players like Confederate-flag booster Rep. Steve King (R-Iowa), who has repeatedly and unsuccessfully introduced bills to end the practice over the years. Deploying active-duty troops en masse as a border protection force seems more at home in the days of Pancho Villa than in the 21st century.

The soldiers, who cannot legally arrest migrants or carry out law enforcement activities, seem to have no real purpose on the border. “I try not to be a cynic, but this just smacks of looking for a political advantage during an election,” said Scott Cooper, a Marine veteran and director of national security outreach for the advocacy group Human Rights First, told Politico. “I think that the military redeploys probably within the next couple weeks and they will have done very little."

Indeed, Politico reported that Trump began talking about Central American migrants after reviewing poll numbers from key congressional districts that found immigration was a key issue.

There is certainly some evidence that these tactics work. For decades, academics have observed a “rally 'round the flag” effect in American politics during times of international crisis. Political scientist John Mueller observed in 1970 that the U.S. president’s approval ratings surged dramatically in the aftermath of shocking and high-profile foreign policy events.

For example, George W. Bush’s approval ratings climbed dramatically after 9/11 and the subsequent invasions of Afghanistan and Iraq. The same seems to hold true in other countries: Russian President Vladimir Putin’s approval ratings rose sharply after his 2014 annexation of Crimea.

Recognition that the president might be “wagging the dog” doesn’t seem to dent this tendency either. Clinton was dogged by the accusation that he had undertaken the bombings in Sudan and Afghanistan to deflect from his sex scandals, but the voting public didn’t seem to care — indeed, he had the highest approval ratings of his career in 1998 and 1999, peaking at 73 percent approval in Gallup’s polls.

But the implications are far larger than poll numbers. The military in particular is seen as a nonpartisan institution, and past presidents might have balked at launching expensive and needless deployments — never mind questioning long-established constitutional principles — for the sake of election advantage.

Trump, however, has shown he is willing to use whatever methods are at hand to try to sway the midterms. No matter what the outcome next week, his ability to co-opt whatever institutions he can may be setting a dangerous example.

Want smart analysis of the most important news in your inbox every weekday along with other global reads, interesting ideas and opinions to know? Sign up for the Today’s WorldView newsletter.