Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Issue with SSI include of embedded component

Avatar

Level 5

Hi All,

I have a component embedded directly into the page something like below:

<div data-sly-resource="${@path = 'somecomponent',resourceType='someproject/component/somecomponent'}"></div>

Now when I add this resourceType to SSI include config, this throws a not found error on dispatcher. This is because dispatcher is trying to access as below:

<!--#include virtual="/content/somesite/en/_jcr_content/somecomponent.nocache.html" --> (This doesn't exist in publish)

  • As we are embedding this component and until the component is not authored component node will not be created.(This component doesn't require authoring)
  • I wrote some code to dynamically generate the node if its not present. For this again I need to reload all the pages which has this component to create the node.
  • When a url is hit on dispatcher, it will indirectly call the publish page and that should generate the node on publish but that's not happening for some reason.
  • I also tried adding the component directly to template jcr:content node but this needs recreation of pages to have the node by default.

Please let me know some solution where in I don't need to manually author all pages or reload all pages.

1 Accepted Solution

Avatar

Correct answer by
Level 5

Atlast fixed it from dispatcher end and came to know few new things about AEM.

/content/somesite/en/_jcr_content/somecomponent.nocache.html

if the somecomponent node is not present in crxde and if we pass the resourcetype to the url. It will call the somecomponent internally.

something like below

/content/somesite/en/_jcr_content/somecompoent.nocache.html/project/components/somecomponent

SSI is already doing the job when the node is not present. It is including the url with resource type appended as told above.

<!--#include virtual="/content/somesite/en/_jcr_content/somecomponent.nocache.html/project/components/somecomponent" -->

Actual issue was dispatcher calling with appending .html at end like
/content/somesite/en/_jcr_content/somecomponent.nocache.html/project/components/somecomponent.html which was giving a not found in publish environment.

wrote dispatcher rewrite rule to stop appending .html specific to url containing .nocache.html/

Now it works fine. Thanks all

View solution in original post

6 Replies

Avatar

Level 10

Do you have this component on the publish instance? Does it work if you do not use SSI?

Avatar

Level 5

Hi Susheel,

I have couple of more Question along with Smac Question.

1. Without loading the Page you want to create the node i.e pages are already there in production so you don't want to reload all pages.

is it right?

2.What ever pages are all there in prod. do you need one time node creation?

3.For new pages after creating the Page. Does author will open the pages?

3 Question Expected answer- If author open the pages after creating for new pages: for that case you create one java class that will instantiate on component load that will check the node on the current page if the node does't exist create node else not.

2 Question Expected- If all pages are on prod. to create a node one time to all pages on the prod without pages reload :

Option 1: create a dummy component that will call the java class on activate method write the java code to iterate through your pages using page manager api and check your template or use Query builder to find the pages created by your template and then iterate through those pages to check the node is exist or not if not create the node.

Option 2:Create a service having configuration of your path, template name, options like disable and start service option to start and disable this service(if you have multiple path and different template)  that will call the java class on activate method write the java code to iterate through your pages using page manager api and check your template or use Query builder to find the pages created by your template and then iterate through those pages to check the node is exist or not if not create the node.

there are other option too to achieve the same results.

Thanks

Avatar

Level 5

Yes it works if I load the page but not the direct component.

/content/somesite/en.html

When I load the above url components load correctly on page

But when I tried to access the component directly it wont as the node is not present

/content/somesite/en/_jcr_content/somecomponent.html

Avatar

Level 5

Q1 - Yes

Q2 - I don't want to write any code to loop through all pages and stuff. Just want to make sure if any other way, without writing any extra code.
Q3 - Yes - I already mentioned in question that I wrote code to generate the node if not present. This is fine for new pages. I am talking about existing pages.

Avatar

Level 5

yes you can do one thing.

1.First take the package of single component.And then extract it.Go to .content.xml of your component then took only component XMl. like secondary_nav_text in below example.

1Then take the whole package of your content and Extract the package and find you template name in Notepad++ this will give you all the path of matched template name.

Those will be in .content.xml then find common things based on the page structure that will be common in content and replace with that suppose my page having parsys before that component is rel_par then i will find </rel_par> and replace with our component xml including search term. It depend on your common thing.

</rel_par>

<secondary_nav_text_l

                        jcr:created="{Date}2017-02-01T19:44:30.089+05:30"

                        jcr:createdBy="admin"

                        tertiarytitle="All "

                        tertiaryurl="test.html"/>

and then create the package again and then deploy it on testing server to test everything is fine.

This might be helpful that required no code.

Avatar

Correct answer by
Level 5

Atlast fixed it from dispatcher end and came to know few new things about AEM.

/content/somesite/en/_jcr_content/somecomponent.nocache.html

if the somecomponent node is not present in crxde and if we pass the resourcetype to the url. It will call the somecomponent internally.

something like below

/content/somesite/en/_jcr_content/somecompoent.nocache.html/project/components/somecomponent

SSI is already doing the job when the node is not present. It is including the url with resource type appended as told above.

<!--#include virtual="/content/somesite/en/_jcr_content/somecomponent.nocache.html/project/components/somecomponent" -->

Actual issue was dispatcher calling with appending .html at end like
/content/somesite/en/_jcr_content/somecomponent.nocache.html/project/components/somecomponent.html which was giving a not found in publish environment.

wrote dispatcher rewrite rule to stop appending .html specific to url containing .nocache.html/

Now it works fine. Thanks all