How does one pass an xml application the communityid and contenttype id for new content item?
What I want to do is to populate a drop down list (on the form for this new item) depending on the communityid and contenttypeid when a user creates a new item. For the sake of simplicity, lets say that i want to populate a drop down list of names for a particular community. names that should show up will be different for different communities. We have a table in the backend that will return the names given a particular community id.
I’ve tried to use Content Item Data / System/sys_communityid and Content Item Status/CONTENTSTATUS.COMMUNITYID but both are to no avail (I believe the problem lies in the fact that when creating a new item, that item clearly hasn’t been created until the form is submitted). The HTML parameters don’t work as the only parameter apparently passed when creating a new content type is the folderid (and another two variables that don’t relate)
The content type and community cannot be set in this manner.
Each XML content editor application is connected to a single content type, and to create an item of that type, you have to open the correct XML application.
The Community of any newly created item is determined by the current login community of the user.
The only way around this that I can see is to produce your own form (in a JSP, perhaps) and use the Services API to create the item in the background. You can then “redirect” to the content editor for that specific content type. Even then, setting the community will be tricky. It can be done, but I don’t believe that you can do it with documented API methods.
Obviously, this is a lot different from the approach you are asking about.
I guess my question is how is the form getting the communityid and contenttypeid (which are set in the hidden fields)? I am not trying to create the item automatically, i just want to pass those variables on to the xml application so that i can display the appropriate list / choices.
I could do away with the contenttypeid as i can hard code that in the parameters i pass to the xml application (as i will have to do this for specific field in a specific content type anyway, i will know that information). So really, all i need is the communityid of the logged in person (or the current community that the person has chosen)…is there a variable that i can use that way (I expected it to be in user context)…?
The XML app would populate a dropdown list in the content editor screen (the form when creating/updating a content item). (ie in the below example, it would populate the drop down with a list of names that we would like to be community specific)
Ie. in workbench for the particular field for the particular content type, we populate the choices via “Retrieve from xml application” and pass the parameters via the “…”
[QUOTE=jitendra;5069]
Just as a side note, but is there a better way to add the pre-exit other than copy/pasting from a existing application that already has one? [/QUOTE]
You should be able to drag and drop the pre-exit from the XML Server View. If you open the “Extensions” and then “Request Preprocessor” categories, you should be able to browse to the pre-exit you want and then drag it to the left side of the query resource.
Note that this only works in the XML Server View. If you go to the System Design View, you will also see the extensions, but these extensions are not draggable for some reason.
Thanks for the info. I had forgotten about the help in WB. I usually just do a search across the Technical Reference Manual and while there was information about the exits, I never got to a part where is actually said how to add them.
In the sql statement, to get the single html parameter (from the pre-exit) and the parameter of the content id (which is passed as a parameter in the field of the content type to the xml application) we use
communityid = ':"PSXSingleHtmlParameter/sys_community"' AND contenttypeid = ':"PSXPARAM/contenttypeid"'
Is this the correct way to reference those variables (i mean it works, but is that the official way to do it?)
I was reading through this thread and I understand the way to pass community_id as a parameter and match it to a hidden field. Is there a similar way to pass site_id as the paramter and match it to a hidden field called siteid?
You could try to get the site id parameter from the url using PSXSingleHtmlParameter/sys_siteid (I have not tried it)…but the problem is that the parameter may or may not exist. Also note that a content item can be in multiple sites (whereas it can only be in one community). The better question would be what problem are you trying to solve by matching the site ids?
We have a content type called category. Users are going to create a few of these items in every site we have. For a different content type called newsroom, we have a field called category. This is a drop down field and we want to populate it using all the category content items of the site under which the newsroom content item will be created. In essence the values are going to be different if the site is different. In our case we have multiple sites in one community and we make sure we do not have a content item on multiple sites.
Also site_id is not available as a HTML parameter. I see that you have passed in contentid as a parameter though it is not supplied in the session. How did you manage to do that?
Ravi,
I cannot pass the content id as a parameter (see dbenua’s reply to my first post). When an item is initially created, it does not have a content id (until you hit submit). I can pass in the content type id though…
We had a problem similar to yours. And we came up with two different solutions…neither of which we implemented because we decided to let the end users pick their own category content item using a slot (as opposed to picking from a drop down)…
#1: Create a “category” content type. Create a jsp page whose output is an xml doc that can be read by the drop down field. This jsp would take the community id of the requestor and figure out the categories that were created under that community.
#2: Create a “category” table in RX with a community id, category short name, category name as the columns. Create an xml app to display the keywords from the table given the community id. Create a jsp page to manage the keywords for a given community.
For you, I think solution 1 is a viable option as the jsp page could figure out the site id based on a folder id that should also be passed to it. (Note that the folder id would only be available if the new content id is placed under a folder…you probably want to do some checking to make sure that the folder resolves to a particular site…and not //Folders/)
Jit,
Thanks for the reply.
I think solution 1 might work in my case. I item is definitely created under a folder which should ( in theory) give me access to the site id. Have you come across any documentation available in how to create these jsp pages and how to automatically populate them and how can I use them to poppulate the dropdown?
There should be documentation on how to populate a drop down list with an xml app…you should just be able to change where the url points to your jsp page. In terms of the jsp, I would just create it under /user/pages. In the list of DTDs there should be one that you can follow (This is for the XML that the jsp page would produce). I don’t know which one it is off the top of my head.
Percussion may have a better solution for you…so you may want to ask them if this a good way to do what you want before going too far along…