• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Showing a single Category

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid not. To list only the categories is very easy, since all you have to do is to edit forum_list.htm and remove the <#list> block from the forums part.

However, for the second part, you will have to code a little bit. The easier way is to create a new method in the class ForumAction named, say, "forumsByCategory".. it may look as



of course this is just an example, and you may want to take a look in some other actions to see the pattern of setting up the context and the template name to use.

For instance, if you want to have friendly urls, as "forums/byCategory/3.page", you will have to change the file "WEB-INF/config/urlPatterns.properties".

Is not a hard work.. it's all a matter of setting up some files

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to show a single category and its forums on a page?
We are trying to setup a forum and it's going to have 4 categories which will be accessed through one starting page which is going to link directly to one of the 4 categories.
[originally posted on jforum.net by neuromancer]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if I understood. You want to have a separate page listing for each category? I mean, by default, the main page of jforum shows this:

Category 1
Forum 1.1
Forum 1.2

Category 2
Forum 2.1

Category 3
Forum 3.1

and what you need is

Category 1
Category 2
Category 3

which then, when the user clicks in the category's name, a new page will open, showing all forums from that category. Is that right?

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly that's what I would like. Is this possible without having to change the java-code?

Ton
[originally posted on jforum.net by neuromancer]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rafeal,

Consider a slight varaition to this scenario. If I want to list categories based on a variable of my application.

suppose I want starting page( i will like to address it as board1) to list categories based on my appl variable, say x=1

category 1
forum 1.1
forum 1.2
category 2
forum 2.1
forum 2.2

and when x=2, board2 shows
category 3
forum 3.1
forum 3.2
category 4
forum 4.1
forum 4.2

1. Is there a db table which stores the board information? is there an outer wrapper that stores the list of category_id and board_id?

2. If there is no board information and still if I want to store the relationship in between my variable and categories in one of my created table outside jforum db, will I have to change java code of Jforum or can I write my own servlet external to Jforum to keep track of new and deleted categories.

I want to minimize the customization in your code for the simple reasons of adapting new releases of Jforum and so that I don't have to redo the customization again in your code.

thanks,
Rashmi



[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Rafael,

I have the same purpose, which is creating new page.

I modified forum_list.htm to show the list of categories. Those link can be clicked by adding ${category.name?html}

I also made changes on :

TemplateKeys.java ==>

public class TemplateKeys
{
private TemplateKeys() {}

public static final String FORUMS_LIST = "forums.list";
public static final String FORUMS_SHOW = "forums.show";
public static final String FORUMS_PING = "forums.ping";
public static final String FORUMS_BANNED = "forums.banned";
public static final String FORUMS_CATEGORY = "forums.category";
...........

ForumAction.java ==>

public void forumsByCategory() throws Exception{
Category c = new Category();
c = ForumRepository.getCategory(this.request.getIntParameter("categories_id"));

this.setTemplateName(TemplateKeys.FORUMS_CATEGORY);
this.context.put("getCategory", c);

}

templateMapping.properties ==>

forums.category = forum_by_category.htm

urlPattern.properties ==>

forums.category.1 = categories_id

and create this page (forum_by_category.htm) ==>

.....
<#list getCategory as category>
<tr>
<td class="catleft" ><span class="cattitle">${category.name}</span></td>
<td class="catright" > </td>
</tr>

<#list category.getForums() as forum>
<#assign lpi = forumRepository.getLastPostInfo(forum.id)/>
<tr>
<td class="row1" >
<#if forum.unread>

<#else>

</#if>
</td>
<td class="row1" >
<span class="forumlink">${forum.name?html}</span>

<span class="genmed">
${forum.description?default("")}
<#if forum.isModerated()>

Moderated Forum

</#if>
</span>


</td>
<td class="row2" ><span class="gensmall">${forum.totalTopics}</span></td>
<td class="row2" >
<#assign total = forum.totalPosts/>
<#if (total == 0 && forum.totalTopics > 0)>
<#assign total = forum.totalTopics/>
</#if>
<span class="gensmall"><#if (total > 0)>${total}<#else>${I18n.getMessage("ForumListing.noMessages")}</#if></span>
</td>
<td class="row2" >
<span class="postdetails">
<#if (lpi.postTimeMillis > 0)>
${lpi.postDate}

<#if (lpi.userId > 0)></#if>${lpi.username}

<#assign startPage = ""/>
<#if (lpi.topicReplies + 1 > topicsPerPage)>
<#assign startPage = ((lpi.topicReplies / topicsPerPage)?int * topicsPerPage) +"/"/>
</#if>

<#assign url = JForumContext.encodeURL("/posts/list/${startPage}${lpi.topicId}") + "#" + lpi.postId/>

<#else>
${I18n.getMessage("ForumListing.noMessages")}
</#if>
</span>
</td>
</tr>
</#list>
</#list>
<!-- END OF FORUM LISTING -->
......

but when clicked one of the category.. it's going nowhere.. it still display the same page.

Is there any other file that I need to be configured?

Thanks

-hanapewee-



[originally posted on jforum.net by hanapewee]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!