We have a template that addresses the various trainings my organization offers. It is a pretty standard template from a content perspective, including a particular paragraph that appears on every individual training page, in the middle of the rest of the content for this page.
My question revolves around how to best handle this paragraph. It will be updated very infrequently, and must be included on every page.
[li]Having a space for it to be pasted in the Content Type will introduce inconsistencies, as well as make it a headache if it ever does need updating.[/li]
[li]Hard coding it in to the template works, but makes it inaccessible to pretty much everyone except devs.[/li]
[li]Creating a slot for it seems like overkill, and again means extra work for the content owners, who must remember to add that page to any new training page, though I suppose you could make an auto Slot work.[/li]
[li]A dispatch template seems like it might be a viable option, but as new as I am to Rx, I am a bit unclear on whether this would be appropriate or even possible.[/li][/ol]
So what is the most appropriate solution? I am hoping I am missing something obvious here.
What we have done in the past is publish the paragraph as it’s own html file without any html tags and use server side includes in the template to pulll the html file in to the page. One benefit is that you don’t need to publish all the content when a change occurs with in the paragraph, you just need to re-publish the paragraph content. I would like to hear other solutions to this problem.
In the middle of the page? That makes it interesting. Since you want to split the Body field in half, not append or prepend the paragraph, I don’t think a normal SSI would work easily. I don’t think using a dispatch template would help particularly either - that would just pick which Generic template to use. If the paragraph always appeared second on the page, or third, maybe you could write code that inserted it in the correct place in the template using $rx.doc.getDocument() But I think users would try to type it in again because it wouldn’t be visible in Ephox.
Using Ephox Edit Live to insert a special Rhythmyx template might be the better solution. Users could choose where to put it, but couldn’t edit it. And Ephox seems to be a little easier to use than a typical slot in the Table Editor.
I’ve used the Brief content type for text that needs to appear on every page. It is a content type that has a callout field. End-users insert that brief as an inline variant (S-Callout) into a slot to appear at the end of a page, usually. When that line or paragraph of text needs to change, the brief item is updated, and then the inline variant updates on all pages during the next publish. (note: the Brief Content Type was part of FF for 5.7)
You may be able to do something similar, although it won’t fully eliminate placement within the page inconsistencies, unless you could create an add’l field in the content editor and then separate “body1”, “slot for brief”, “body2” in the template.
The auto slot idea came to me as I wrote the original post. Seems to be working pretty well in the first experiment.
I created the paragraph using a generic content type, then created an auto slot that grabs the content using the sys_title field (moderately unique).
SELECT rx:sys_contentid FROM rx:Generic WHERE rx:sys_title = 'My Paragraph'
Drop the slot in to the template, and voila!
However, there are two drawbacks to this particular method.
[li]If anyone ever changes the the system title of that paragraph, it will break.[/li][li]I have to create a unique slot each time I need to do this.[/li][/ol]
I also suppose I could create a unique content type for these sorts of issues, where a particular field becomes read-only after creating the content, and build the query from that field. This would solve issue #1.
It also suddenly occurs to me that I might be able to pass the SQL of an autoslot in the parameters section of a slot snippet. If I can do that, then #2 is moot as well.
However, there are two drawbacks to this particular method.
There’s another one. Any page that contains an autoslot will be fully published as part of an incremental run.
Yes, you can pass the query (and its parameters) from the template rather than in the slot.
Normally, this is how you should do it.
Seems there is no perfect solution.
I wonder though - is there a way to force content into a standard slot without the user having to do anything? Basically, do what I am doing in the auto slot, but using a relationship slot instead?
You can do this, but it requires Java. You can auto create ‘standard’ relationships in a content type post exit. When the item is created, you create the link. Then on a save, the code could verify that the link was still present and re-add it if necessary.
The exit could be parameterized for the template, and target item id (which would be better than the sys_title unless the item hasn’t been created yet.)
This may not be a solution to this specific problem, but I have noticed that the output of the page template is stored as an ordinary Java string in $sys.innercontent and thus could be manipulated using any of the methods listed at http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html in the global template. For example:
$sys.innercontent.replaceFirst("</p>", "</p><p><strong>NOTE: Something important to be placed in all pages immediately following the first paragraph</strong></p>")
It’s a crude hack, but I’m getting use to having to resort to those. The second parameter to the replaceFirst method could be a variable set by calling a slot of the navtree, in which could be placed the content item containing the fixed, standard text for an entire site. There are examples already on these forums of the hacks needs to get that working in the snippet template used by the slot.
[QUOTE=paulhoward;4144]You can do this, but it requires Java. You can auto create ‘standard’ relationships in a content type post exit. When the item is created, you create the link. Then on a save, the code could verify that the link was still present and re-add it if necessary.
The exit could be parameterized for the template, and target item id (which would be better than the sys_title unless the item hasn’t been created yet.)[/QUOTE]
Basically, after doing some looking around, you are talking about a reverse of the post exit rxs_BuildRelationshipsFromIds, correct? Not terribly familiar with how to code java, but I’ll see what I can do.