We have some legacy pages where the channel page contains a content instance with the same name. Both the channel and content instance have SEO tab where users can populate the meta tags for title, description and keywords. For these pages, we would like to use the SEO values from the content instance rather than the channel page. Our template code refers to the content instance in the following manner:
<page:contentRegion name="<somename>"
types="VgnExtQuery" scope="template" displayInContextEdit="true"
jsp="<somedisplayview.jsp>" />
In the displayview.jsp, we try to get the metatitle and metadescription:
reqContext = PageUtil.getCurrentRequestContext(pageContext);
channel = reqContext.getRequestedChannel();
if(reqContext.getMetaTitle()!=null)
metaTitle = reqContext.getMetaTitle();
if(reqContext.getMetaDescription()!=null)
metaDescription = reqContext.getMetaDescription();
QueryContentComponent qc = (QueryContentComponent)reqContext.getRenderedManagedObject();
if(qc != null){
List results = qc.getResults(reqContext);
if(results.size() > 0){
ci = (ContentInstance)results.get(0);
}
}
It seems in this case, the requestContext here returns the channel page rather than the content instance pageand we are not getting the metaTitle or metaDescription from the content instance page, just the channel page.
How can I extrapolate from here to get the meta tags that I want?
Thanks,
Christine