Hi, our company is new to CQ5.
We have blog post pages, and part of their data is title, hero image and short description of the blog post.
We want to pull that data (I assume it lives in /content folder in the JCR) and put it into other components we use around the site. Specifically we want a sort of "blog sneak peak" component that can go on any page and links to the whole blog post. Surely that's right up CQ's alley, but we're not sure how. Can someone layout the general process we'd use to do this? To us it seems strange to have to use an API to access this data.
Regards,
Roneesh
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ron,
There's probably a half dozen ways to do this depending on the particulars. Here's one...
For your blog post page component, add a new script, called (for example) "teaser.jsp". In this script, output the HTML for the blog entry which would be visible in this sneak peak context. Maybe it is just the headline, title, and link. I don't really know.
Then, in your "blog sneak peak" component, give the author a pathfield allowing them to select the blog entry (assuming this what you want). Let's call that property blogEntryPath.
Then, in the script for the sneak peak component, do something like this:
<sling:include path="${properties.blogEntryPath}" replaceSelectors="teaser"/>
This will cause the blog entry to be rendered using the teaser script.
Regards,
Justin
Views
Replies
Total Likes
Hi Ron,
There's probably a half dozen ways to do this depending on the particulars. Here's one...
For your blog post page component, add a new script, called (for example) "teaser.jsp". In this script, output the HTML for the blog entry which would be visible in this sneak peak context. Maybe it is just the headline, title, and link. I don't really know.
Then, in your "blog sneak peak" component, give the author a pathfield allowing them to select the blog entry (assuming this what you want). Let's call that property blogEntryPath.
Then, in the script for the sneak peak component, do something like this:
<sling:include path="${properties.blogEntryPath}" replaceSelectors="teaser"/>
This will cause the blog entry to be rendered using the teaser script.
Regards,
Justin
Views
Replies
Total Likes
Justin, thanks for your reply, I really appreciate it!
Can you explain this part of your proposed solution?
replaceSelectors="teaser"
what exactly is that part doing?
Views
Replies
Total Likes
Also Justin, let's say in our "blog teaser" component, we want our content authors to just be able to select the blog post the teaser is for via a drop-down field in the dialog.
Is there a way we could do something like:
${sling:getResource(resourceResolver,'/content/blogs')}"
And they could get a drop-down of blog content nodes?
Sorry for the vagueness, I'm new to CQ, and not even sure if sling:getResource is correct. If you're not clear on what I'm saying, please let me know! Slowly but surely I'm learning though!
-Roneesh
Views
Replies
Total Likes
Typically you would not use a drop down for that functionality, but rather a pathfield widget (which is what Justin mentions in his comment). The path field widget is used to select pages from the repository and stores the path to the page in the component's content.
Views
Replies
Total Likes
just like the way you can output node content using .xml suffix to a url, you can write some selector which outputs text in html format
for your component jsp. (you cannot output image, so give a reference path to image etc).
>>"blog sneak peak" component that can go on any page and links to the whole blog post.
its not clear what you mean by component can go any page ... if you are referring to an author utility component which
author can use to link another post then you can go on implementing a "path" type which lets author browse the repository and get the path.
Views
Replies
Total Likes
Hi Venu, thanks for your reply, can you explain how to do a few things you mentioned?
1. How can you write a selector which outputs text in html format? Can you show me a code example?
2. Can you show me how to implement a "path" type which lets the author browse the repository and get the path?
To clarify, we have multiple pages for products and multiple different pages for blog posts. On the product pages we want to be able to place a "blog teaser" component, which is information gotten from the blog post pages and the component has a link to the full blog post. So rather than have our authors write that themselves, we'd rather they just select the blog post they want to reference and that "blog teaser" component populate from the blog post node content.
Thanks everyone!
Ron
Views
Replies
Total Likes