Score:0

Is there Drupal Twig built-in ability to get content of page

cn flag

Is there built in Drupal Twig ability (tag) to get content of another website's page like file_get_contents() or cURL do in PHP? Under "built in" I mean without adding a PHP code to a controller for example a variable to hook function of a theme?

john Smith avatar
gr flag
AFAIK the simple answer is no
leymannx avatar
ne flag
`<iframe src="https://another-website.com/page" title="Another Website Page"></iframe>`, see https://www.w3schools.com/tags/tag_iframe.asp. Or maybe you mean https://twig.symfony.com/doc/2.x/functions/source.html or https://www.slideshare.net/javier.eguiluz/twig-tips-and-tricks/72-source_filegetcontents.
cn flag
@leymannx I mean getting content of external resourse like `get('https://example.com')` and just via Twig syntax, not via iframe I know about of course. As I understand, `source()` can get only a template by its "inner filesystem path" and which is hosted at the same hosting, right?
cn flag
Having the ability to do this would open up a potentially horrific security hole, so I doubt core Twig or Drupal would support such a thing.
cn flag
For reference, Views (in core) can be used to show content from another site that is available via RSS, and Feeds (in contrib) can pull in content in a variety of ways.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.