cancel
Showing results for 
Search instead for 
Did you mean: 

Detailed space view according to content type

david_labbe
Champ in-the-making
Champ in-the-making
Hi there,

after perusing through the forums, I found out how to create customized detailed view (see http://forums.alfresco.com/en/viewtopic.php?f=12&t=25906).

The only issue is that it implies that all the content in a given space will be shown identically.

Is there a way to list the contents in a space according to their types, i.e.:

say we have 2 types:
- a purchase order type with custom properties such as Vendor, Items, Amount, Currency… (there could be others obviously…)
- a report type with custom properties such as Author, Project Number, Description, Reviewer

How could I show in the detailed view in a space the following [img]http://farm5.static.flickr.com/4035/4623395595_c77a768d3b_b.jpg[/img]

Thanks very much for your help.
11 REPLIES 11

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
The only issue is that it implies that all the content in a given space will be shown identically.

This is wrong, you can create if statements and split content by type.

david_labbe
Champ in-the-making
Champ in-the-making
Thanks for your reply. Could you give me a bit more details of how to do that, maybe an example of code doing that?

thanks

David

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
space is current space

<#list space.childrenByLuceneSearch[" +TYPE:\"cm:content1\""?sort_by(['properties','cm:modified'])?reverse as child>

<#if (child.hasPermission("Read"))>

create table hire

</#if>
</#list>

<#list space.childrenByLuceneSearch[" +TYPE:\"cm:content2\""?sort_by(['properties','cm:modified'])?reverse as child>

<#if (child.hasPermission("Read"))>


create table hire
</#if>
</#list>

<#list space.childrenByLuceneSearch[" +TYPE:\"cm:content3\""?sort_by(['properties','cm:modified'])?reverse as child>

<#if (child.hasPermission("Read"))>

create table hire

</#if>
</#list>

david_labbe
Champ in-the-making
Champ in-the-making
[sorry post erased due to mistake]

david_labbe
Champ in-the-making
Champ in-the-making
After a little investigation, I am gathering your code would go in a template that should get applied to the desired space.

That's cool, but what I am after is not a template but rather, a way of modifying the browse.jsp file so that accross all the spaces, a standard set of list according to content type is available. Quite importantly, if no content of a certain type is present, then the list for that type is simply not shown (i.e. no "No items to display .. blablabla", no listing at all!).

if I create a new rich list in the jsp file and ensures that its columns get rendered if the content type is of a certain value, then this works (…ish… I get a java lang exception that I need to look into). It's just a little bit heavy handed!

Thanks

David

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
Well, that what are you asking for is not so hard to do.
you need to overrice BrowseBean.java and add  binding (looks like this )binding="#{BrowseBean.spacesRichList}" , also add methods to return your nodes of certain type .

in browse bean add  a:richList(s) s, how many you need.


and in method that return nodes you must parse nodes by type like:

Repository
          .getServiceRegistry(FacesContext.getCurrentInstance())
          .getDictionaryService().isSubClass(s,
             ContentModel.TYPE_CONTENT) //you would have your custom type hire

of course you define type ( in java class so it would be easier to use it )
static final QName TYPE_CONTENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "content");
//you put your custom stuff.( like so  static final String CONTENT_MODEL_1_0_URI = "http://www.alfresco.org/model/content/1.0";

and his is it, really easy .

david_labbe
Champ in-the-making
Champ in-the-making
thanks for your reply.

That sounds promissing. I am sure it is very easy to do but I am a total newb at Java (my background was php and I am switching over for the purpose of Alfresco!). Would it be too much asking you to detail a bit more how you achieve all this (I know it sounds like I am asking to be taken by the hand… well yeah! that's exactly what it is!) :-)…

Thanks

David

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
I am sorry about that I can not print you code but I can tell you what you need do.

Task 1: override BrowseBean
    ( if you have project in eclipse you face faces-cusom.xml )

create class ort.somepackage.CustomBrowseBean
go to tomcat/webapps/alfresco/WEB-INF/FACES-CONFIG-BEANS.XML
copy paste the part
   <managed-bean>
      <description>
         The bean that holds folder browse state.
      </description>
      <managed-bean-name>BrowseBean</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.BrowseBean</managed-bean-class>
….
to faces-config-custom.xml .

change <managed-bean-class>org.alfresco.web.bean.BrowseBean</managed-bean-class>
to
<managed-bean-class>ort.somepackage.CustomBrowseBean</managed-bean-class>

Task 2: checkout how it works with content list
  attach the source from alfresco api and look at the code, to understand the binding and content list
  

Task 3: create few methods splits content by file type use that dictionary part
this is easy no explaining needed



Task 4: open browse.jsp copy paste a:list part and change the binding and value and columns values, in tast 2 you should see how this works and added needed methods and params.
——————————-
you should try it and if you have a problem let me know, only way to learn is to try.

PS: I assume that you have types part done .

david_labbe
Champ in-the-making
Champ in-the-making
Thanks Savic,

you are absolutely right! The only way to learn is to try. Believe me, I have been learning a hell of a lot since I started playing with Alfresco about 1 month ago! The thing is that I have to learn both Alfresco and Java and that is not a small job! Pretty steep learning curve on both!!!

Anyway, I will try what you suggested and will let you know if I have managed!

Cheers

David