Skip to content

Instantly share code, notes, and snippets.

@000benniu
000benniu / sample.html
Last active October 30, 2023 01:32
Object/Headless API fragment
<div id="loadmore" class="btn btn-sm btn-primary">データ取得</div>
<div id="loadmore2" class="btn btn-sm btn-primary">データ取得&画面更新</div>
<?xml version="1.0"?>
<workflow-definition
xmlns="urn:liferay.com:liferay-workflow_7.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:liferay.com:liferay-workflow_7.4.0 http://www.liferay.com/dtd/liferay-workflow-definition_7_4_0.xsd"
>
<name>e2426a9f-ae0c-8cff-5733-53ee5b5f123e</name>
<description>重要なお知らせに対し、広報室長がレビューする</description>
<version>26</version>
import com.liferay.portal.kernel.exception.PortalException
import com.liferay.portal.kernel.model.User
import com.liferay.portal.kernel.service.UserLocalServiceUtil
try {
// You can replace 'userId' with the actual user's ID
def user = UserLocalServiceUtil.getUser(44386)
def companyId = user.getCompanyId()
println "Company ID for User ${user.getScreenName()}: $companyId"
} catch (PortalException e) {
@000benniu
000benniu / ConditionSample.txt
Last active December 9, 2022 02:39
Kaleo Condition Check script Sample
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.kernel.service.ServiceContext;
try {
System.out.println("=====================Start Script================================");
System.out.println("=====================workflowContext================================");
workflowContext.each{ k, v -> System.out.println "${k}:${v}" }
<#include "${templatesPath}/NAVIGATION-MACRO-FTL" />
<#if !entries?has_content>
<#if themeDisplay.isSignedIn()>
<div class="alert alert-info">
<@liferay.language key="there-are-no-menu-items-to-display" />
</div>
</#if>
<#else>
<#assign
[#assign assetEntry = "" /]
[#assign trackingId = "" /]
[#assign infoListDisplayObject = (request.getAttribute("INFO_LIST_DISPLAY_OBJECT"))! /]
[#assign liferaySharedLayoutAssetEntry = (request.getAttribute("LIFERAY_SHARED_LAYOUT_ASSET_ENTRY"))! /]
[#if infoListDisplayObject?has_content]
[#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService") /]
[#assign modelClassName = infoListDisplayObject.modelClassName! /]
[#assign resourcePrimKey = infoListDisplayObject.resourcePrimKey! /]
<#--
Dump all the values for web contents.
Use as asset publisher's template. (tested on DXP 7.1)
-->
<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
<#if entries?has_content>
<#list entries as curEntry>
<#assign journalArticle = journalArticleLocalService.getLatestArticle(curEntry.getClassPK()) />
<@liferay_journal["journal-article"]
@000benniu
000benniu / related_asset_fetch_sample.ftl
Created April 6, 2022 06:17 — forked from yasuflatland-lf/related_asset_fetch_sample.ftl
Fetch Related Assets in Web Content Template
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- <#assign foo = something.in["your"].data[0].model />
--
-- <@dumper.dump foo />
@000benniu
000benniu / liferay_dump_for_fragment
Created March 16, 2022 06:49
liferay_dump_for_fragment
[#assign black_list = ["class", "request", "getreader", "getinputstream", "writer"] /]
[#macro dump key data]
[#if data?is_enumerable]
enumerable:<b>${key}</b>
[@printList data,[] /]
[#elseif data?is_hash_ex]
hash_ex:<b>${key}</b>
[@printHashEx data,[] /]
[#else]