Is it possible to determine if a particular content type is being used (inline and within a slot) when generating the location scheme?
Some Background:
We would like to create a php content type that say has a field to insert php code. We would like to embed that into other pages by 1. inline (via ephox editor) and 2. as a slot item. On publishing, we would like to figure out if that content type is being used and if so, then give the page and extension of “.php” or else it would get the standard “.html” extension.
Ahh…I didn’t clarify my original request well enough. Yes, that code does work for determining say the original content type (i’ve used $relresult.getNode().getPrimaryNodeType().getType() as most of my checking for content types are done within a raw slot macro, but i digress). What i need is the content types/templates being included WITHIN the primary content type.
For example say the pgGeneral (template) which is for ctGeneral (content type) has a slot (say slStuff). In both the body (as an inline template) and in the slot, i can “add”/reference another content type (say ctPHP) with its unique template (say snPHP). So the question becomes, when publishing pgGeneral, how can i figure out that snPHP is “part” of the rendered page (and thus give pgGeneral and extension of “.php” as opposed to “.html”?
I have tried a variety of methods, even stooping so low as to attempt to do a match function to see if i could get at the rendered page (and see if a particular text was found), but no luck.
In a location scheme, you don’t have an assembly item, but you can access JEXL functions.
To find the included content types, you’re going to need to create your own JEXL function in Java. This JEXL function will use the IPSContentWs.loadContentRelations() method to find the contents of the appropriate slots. (This function works a lot faster if you do NOT need to load the reference info).
Once you’ve identified the items in a required slots, you will have to load the component summaries for all of these items with IPSCmsContentSummaries.loadComponentSummaries().
These summaries contain the content type id.
If you use this function in a location scheme, it will be called for EVERY item that gets published, so it makes sense to try and optimize performance, and to eliminate as many unnecessary steps as possible. You will also want to “fail fast”. As soon as you find 1 PHP content item, you can return true immediately, rather than searching the rest of the slots.
This approach won’t work for Auto Slots, only slots where there is a relationship stored in the tables (Inline Slots are okay)
I also need to get slot information for my Location Scheme. I’m trying to use loadContentRelations, but I can’t find any examples of how it’s used. there’s nothing in the src/ under the Exits directory. I’ve looked through the API PDF and searched the forum. Is there anywhere else that I can find information on how to use this method?
Look at the JavaDoc, which is located at /Rhythmyx/Docs/Rhythmyx/Javadocs/index.html on your server.
The interface IPSContentWs has documentation for this methods.
You need to create a new PSRelationshipFilter and specify the slot id in the relationship properties of the filter (use IPSHtmlParameters.SYS_SLOTID) and set the owner property of the filter to the PSLocator that specifies the parent content item.
Unfortunately, I don’t have a completed sample of this handy, but if you have further trouble, post your code and I’ll try to help you.
Do you mean I that I should update PSFilter like this:
PSFilter.setRelationshipID(IPSHtmlParameters.SYS_SLOTID)
?
I’m thinking that’s wrong. But I can’t figure out what you mean. I have been looking through the API, honest.
[QUOTE=dbenua;11175]April,
Look at the JavaDoc, which is located at /Rhythmyx/Docs/Rhythmyx/Javadocs/index.html on your server.
The interface IPSContentWs has documentation for this methods.
You need to create a new PSRelationshipFilter and specify the slot id in the relationship properties of the filter (use IPSHtmlParameters.SYS_SLOTID) and set the owner property of the filter to the PSLocator that specifies the parent content item.
Unfortunately, I don’t have a completed sample of this handy, but if you have further trouble, post your code and I’ll try to help you.[/QUOTE]
Since I’m in the Location Scheme, and so don’t have access to $rx.session to pass to my extension, how do I get the session? Here’s what I have so far: