Pages

Showing posts with label Pages. Show all posts
Showing posts with label Pages. Show all posts

06 October, 2023

XM Cloud - Troubleshooting the integration of Pages app with local XM Cloud Instance

As per Sitecore documentation, you can connect XM Cloud Pages app to your local XM cloud instance. 

How should you do it? 
  • Once you browse Pages app (pages.sitecorecloud.io), go to browser developer tools --> Application --> Storage --> Local Storage and open the entry for https://pages.sitecorecloud.io.
  • Add a new key and value. 
    • Key: Sitecore.Pages.LocalXmCloudUrl
    • Value: Your local XM Cloud CM instance. Ex: https://xmcloudcm.localhost/
  • Refresh the pages app and it should connect to your local XM cloud instance. 
I was facing some issues after setting it up. 
  1. login.sitecorecloud.io refused to connect or couldn't retrieve the page. 


    This happens when your local XM Cloud instance is not logged in. Make sure you login to use local XM Cloud instance in the same browser (another tab) and this error should go away. 

  2. Pages app does not render the content and components from local XM Cloud instance


    Looking at the console log, a possible certificate exception appeared.



    In the environment file, the public rendering host is www.xmcloudpreview.localhost. The Pages app is using https://xmcloudcm.localhost as the local XM Cloud URL, as we set it in the local storage key Sitecore.Pages.LocalXmCloudUrl. Then, the local XM Cloud instance calls the public rendering host and gets the content. However, the local XM Cloud instance does not have a valid certificate for the public rendering host www.xmcloudpreview.localhost.

    Once the certificate was created and placed in the \docker\traefik\certs folder and the config \docker\traefik\config\dynamic\certs_config.yaml was added, the rendering host public URL started working without any certificate errors and the pages app was also able to render the page for editing.

    Go to \docker\traefik\certs, run mkcert www.xmcloudpreview.localhost and it will create the cert and key. You can refer it in certs_config.yaml and restart the rendering container alone. 

    I am looking for other options or solutions which can fix this issue. If this is the only way, Sitecore can add it as part of their initial XM Cloud local instance setup itself. 





06 September, 2023

Hacky way to open XM Cloud Pages App from Content Editor using Sitecore PowerShell

When a content author is using Content Editor and want to use Pages to edit the pages, author can go to XM Cloud Apps Dashboard and then open the Pages App and then navigate to the appropriate item in the tree. In order to minimize the steps for the content authors, a simple hack in the content editor can help content author to open the Pages with appropriate item directly by click of a link. 

A page with Layout will have option to open it in Pages by clicking here hyperlink.

Sitecore PowerShell Extension is again helping here to set it up. Thanks to Adam Najmanowicz | @adamnaj / Michael West | @michaelwest101 for their effort to develop and release SPE for the community. 

  1. Create a new Module with Content Editor Warning integration point
  2. Go to the module and find Warning script library under Content Editor Warning item
  3. Create new PowerShell Script under that item and name it as Pages.
  4. Add the script with the below code.

Script to enable this feature:


In order to enable this feature only to the items where page layout is present, in the Enable Rule field, add ''where the item has a layout' rule. 



That's it. 

Points to remember:
  • This hacky will enable this option for all the pages where layout is present. In case if your use case is complex, then appropriate rule should be applied. 
  • The Pages link will open in another tab of the same browser. It is assumed that user is logged in to Sitecore Cloud Portal so that pages will automatically login and redirect to the selected item. 
  • Remember - This may not work for some complex Site grouping (have not tested it) but hoping Sitecore to add similar feature to open Pages from Content Editor out of the box 😊

blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }