1

I'm trying to get a page's content dynamically so I can open in a modal. What's the best way of getting the html from a page given an ID/page url?

7
  • 2
    Can you please provide more detail to help people understand you requirement? Commented Jan 12, 2018 at 2:47
  • sure @AmitabhVyas - I have a list of links that point to sitecore content pages. When a link is clicked, I want to get the pages' content and display it in a different format (ex Modal window).
    – Snapper
    Commented Jan 12, 2018 at 2:54
  • 1
    Why not use window.open() passing in the page url (and window options for modal) or use an iframe and set the src property rather than scraping HTML from Sitecore...?
    – jammykam
    Commented Jan 12, 2018 at 3:11
  • thats a good suggestion @jammykam but I wont render all the renderings on the page (Header, footer etc) so I'd like to have control over the different renderings that are to be displayed
    – Snapper
    Commented Jan 12, 2018 at 5:51
  • 1
    @Snapper If you get just the markup and display it on another site, you will need to expand all links to be absolute otherwise images/css/javascript links will not be valid.
    – jammykam
    Commented Jan 12, 2018 at 16:28

1 Answer 1

4

I like the suggestion which is provided by @jammykam. To fit to your requirements I would create a new device and there you can create your own layout for that specific modal. You can create your device under /sitecore/layout/Devices:

enter image description here

Then your new device will apear in the Layout Details: enter image description here

Then you can access to the device related rendering defintion through the following url: http://[url]?sc_device=modal

1
  • 2
    Exactly how we do things too. We typically create a slimmed down layout file specifically for modals too.
    – jrap
    Commented Jan 12, 2018 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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