在 liferay 中对布局和菜单链接进行分类

发布于 2024-12-15 06:07:25 字数 324 浏览 0 评论 0原文

我正在通过带有友好网址的挂钩安装布局

,如下

/cat1/link1、/cat1/link2

/cat2/link3、/cat2/link4

我希望它以这样的方式,当我导航到 cat1/link1 时,

导航链接应该是link1 和 link2

以及当我导航到 cat2/link3 时

导航链接应该是 link3 和 link4

我怎样才能实现这个?

或者任何人都可以建议我如何在同一 liferay 安装中将多个站点的布局分组为不同的类别?

谢谢..

I am installing layouts through the hook

with friendly url as follows

/cat1/link1, /cat1/link2

and

/cat2/link3, /cat2/link4

I want it insuch a way that when I navigate to cat1/link1

The nav links should be link1 and link2

and when i navigate to cat2/link3

The nav links should be link3 and link4

How can i achive this?

or can anyone suggest how can i group the layouts for multiple sites into different categories in same liferay install?

Thanks..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑凤梨 2024-12-22 06:07:25

创建组织(来自 Seven-cogs StartupAction.java

long userId = defaultUserId;
long parentOrganizationId = OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID;

String name = "7Cogs, Inc.";
String type = OrganizationConstants.TYPE_REGULAR_ORGANIZATION;

boolean recursable = true;
long regionId = 0;
long countryId = 0;
int statusId = GetterUtil.getInteger(PropsUtil.get("sql.data.com.liferay.portal.model.ListType.organization.status"));
String comments = null;

ServiceContext serviceContext = new ServiceContext();

serviceContext.setAddCommunityPermissions(true);
serviceContext.setAddGuestPermissions(true);

Organization organization =
        OrganizationLocalServiceUtil.addOrganization(
        userId, parentOrganizationId, name, type, recursable, regionId,
        countryId, statusId, comments, serviceContext);

Group group = organization.getGroup();
GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/7cogs");

您确定需要两个组织而不是两个社区吗?

评论中问题的更新:

要获取主题中的组织名称(velovity),您可以使用(如果您在组织的页面(组)中)

在portal-ext.properties中

journal.template.velocity.restricted.variables=

在主题vm文件

Liferay 6

#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalService"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()

Liferay 5.x

#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalServiceUtil"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()

编辑:

如果您的用户是您可以使用的组织的成员

#foreach($org in $themeDisplay.getUser().getOrganizations())
    $org.getName()<br>
#end

请注意,用户可以是多个组织的成员,您将获得所有组织。

To create organization (this is from seven-cogs StartupAction.java)

long userId = defaultUserId;
long parentOrganizationId = OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID;

String name = "7Cogs, Inc.";
String type = OrganizationConstants.TYPE_REGULAR_ORGANIZATION;

boolean recursable = true;
long regionId = 0;
long countryId = 0;
int statusId = GetterUtil.getInteger(PropsUtil.get("sql.data.com.liferay.portal.model.ListType.organization.status"));
String comments = null;

ServiceContext serviceContext = new ServiceContext();

serviceContext.setAddCommunityPermissions(true);
serviceContext.setAddGuestPermissions(true);

Organization organization =
        OrganizationLocalServiceUtil.addOrganization(
        userId, parentOrganizationId, name, type, recursable, regionId,
        countryId, statusId, comments, serviceContext);

Group group = organization.getGroup();
GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/7cogs");

Are you sure that you need two organizations and not two communities?

UPDATE for question in comment:

To get organization name in theme (velovity) you can use (if you are in organization's pages (group))

In portal-ext.properties

journal.template.velocity.restricted.variables=

In theme vm file

Liferay 6

#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalService"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()

Liferay 5.x

#set($os = $serviceLocator.findService("com.liferay.portal.service.OrganizationLocalServiceUtil"))
#set($organization = $os.getOrganization($themeDisplay.getScopeGroup().getOrganizationId()))
$organization.getName()

EDIT:

If your user is member of organization(s) than you can use

#foreach($org in $themeDisplay.getUser().getOrganizations())
    $org.getName()<br>
#end

Take note that user can be member of multiple organizations and you will get all of them.

情痴 2024-12-22 06:07:25

关于代码您需要了解的内容:

在马丁提到的同一类中,我已经组合了可以实现您需要的代码的组合。

请注意,某些变量未定义。您必须使用 Liferay 安装特有的正确值。例如,userId 可以是任何人,但我建议使用默认用户的 userId 或管理员的 userId。

代码:

Organization organization =
    OrganizationLocalServiceUtil.addOrganization(
        userId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID,
        "My Org 1", OrganizationConstants.TYPE_REGULAR_ORGANIZATION, true,
        regionId, countryId, statusId, comments, true, serviceContext);

Group group = organization.getGroup();

GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat1");

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 1", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link1",
    false, serviceContext);

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 2", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link2",
    false, serviceContext);

organization =
    OrganizationLocalServiceUtil.addOrganization(
        userId, parentOrganizationId, name, type, recursable, regionId,
        countryId, statusId, comments, true, serviceContext);

group = organization.getGroup();

GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat2");

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 3", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link3",
    false, serviceContext);

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 4", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link4",
    false, serviceContext);

What you need to know about the code:

From the same class Martin mentioned I've put together a mix of code that will achieve what you need.

Note that some of the variables are not defined. You'll have to use the correct values that are particular to your Liferay installation. For example, the userId could be anyone but I would suggest using either the default user's userId or an administrator's userId.

The Code:

Organization organization =
    OrganizationLocalServiceUtil.addOrganization(
        userId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID,
        "My Org 1", OrganizationConstants.TYPE_REGULAR_ORGANIZATION, true,
        regionId, countryId, statusId, comments, true, serviceContext);

Group group = organization.getGroup();

GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat1");

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 1", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link1",
    false, serviceContext);

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 2", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link2",
    false, serviceContext);

organization =
    OrganizationLocalServiceUtil.addOrganization(
        userId, parentOrganizationId, name, type, recursable, regionId,
        countryId, statusId, comments, true, serviceContext);

group = organization.getGroup();

GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/cat2");

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 3", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link3",
    false, serviceContext);

LayoutLocalServiceUtil.addLayout(
    group.getCreatorUserId(), group.getGroupId(), "false",
    LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, "My Link 4", StringPool.BLANK,
    StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, "/link4",
    false, serviceContext);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文