我想使用布局自定义此格式的sakai站点工具配置。但默认情况下,sakai布局可以通过双重布局或单一布局实现。实际上我需要第一行的组合是双列布局和剩余的单列布局。
请告诉我有没有选择这样做。或者为我提供如何自定义的指导。我插入的图像我想要像这样的工具对齐
先谢谢 http://i.stack.imgur.com/Xjy17.png
答案 0 :(得分:2)
最后它的工作我这样做了。如果需要,请提供任何建议,以获得更大的灵活性或任何其他方式。
<强>内核强> 的
Sitepage.java: -
添加
public static final int LAYOUT_MY_CUSTOM = 2;
<强> BaseSitepage.java: - 强>
在
中更改此内容protected BaseSitePage(BaseSiteService siteService, Site site, String id, String title, String layout,
boolean popup)
{}
if (layout.equals(String.valueOf(LAYOUT_SINGLE_COL)))
{
m_layout = LAYOUT_SINGLE_COL;
}
else if (layout.equals(String.valueOf(LAYOUT_DOUBLE_COL)))
{
m_layout = LAYOUT_DOUBLE_COL;
}
else if(layout.equals(String.valueOf(LAYOUT_MY_CUSTOM))){
m_layout = LAYOUT_MY_CUSTOM;
}
And
protected BaseSitePage(BaseSiteService siteService, Site site, String id, String title, String layout,
boolean popup)
{} method
else if(layout.equals(String.valueOf(LAYOUT_MY_CUSTOM))){
m_layout = LAYOUT_MY_CUSTOM;
}
And
public void setLayout(int layout)
{
if ((layout == LAYOUT_SINGLE_COL) || (layout == LAYOUT_DOUBLE_COL) || (layout == LAYOUT_MY_CUSTOM))
{
m_layout = layout;
}
else
M_log.warn("setLayout(): set to invalid value: " + layout);
}
<强> BaseSiteService.java: - 强>
public String[] getLayoutNames()
{
String[] rv = new String[3];
rv[0] = rb.getString("sitpag.lay_sngl");
rv[1] = rb.getString("sitpag.lay_dbl");
rv[2] = rb.getString("sitpag.lay_cust1");
return rv; }
的门户: - 强> 的
在方法
中注释以下代码 public void includePage(PortalRenderContext rcontext, HttpServletResponse res,
HttpServletRequest req, Session session, SitePage page,
String toolContextPath, String wrapperClass) throws IOException
{
rcontext.put("pageColumnLayout", (page.getLayout()==SitePage.LAYOUT_DOUBLE_COL) ? "col1of2": "col1");
并替换代码
if(page.getLayout() == SitePage.LAYOUT_DOUBLE_COL){
rcontext.put("pageColumnLayout","col1of2");
}
else if(page.getLayout() == SitePage.LAYOUT_MY_CUSTOM){
rcontext.put("pageColumnLayout","SingleDouble");
}
else{
rcontext.put("pageColumnLayout","col1");
}
并改变
rcontext.put("pageTwoColumn", Boolean
.valueOf(page.getLayout() == SitePage.LAYOUT_DOUBLE_COL || page.getLayout() == SitePage.LAYOUT_MY_CUSTOM));
And
// do the second column if needed
if (page.getLayout() == SitePage.LAYOUT_DOUBLE_COL ||page.getLayout() == SitePage.LAYOUT_MY_CUSTOM)
网站管理: -
SiteAction.java
将自定义布局添加到以下方法8990行
private void addSynopticTool(SitePage page, String toolId,
String toolTitle, String layoutHint) {
if (page.getContainingSite() != null) {
if (page.getLayout() != SitePage.LAYOUT_SINGLE_COL || page.getLayout() != SitePage.LAYOUT_MY_CUSTOM|| !page.getContainingSite().isCustomPageOrdered() ) {
page.setLayout(SitePage.LAYOUT_DOUBLE_COL);
}
}
}
OSP工具
XSltcharon门户网站: -
<强> XsltrenderContext.java: - 强>
评论以下
/*pageElement.setAttribute("layout", (context.get("pageColumnLayout")
.equals("col1")) ? "0" : "1");*/
并替换为
String selectedLayout="0";
//context.put("pageColumnLayout","SingleDouble");
if(context.get("pageColumnLayout").equals("col1of2")){
selectedLayout="1";
}
else if(context.get("pageColumnLayout").equals("SingleDouble")){
selectedLayout="2";
}
else{
selectedLayout="0";
}
并在if(selected)
中添加以下语句if(context.get("pageColumnLayout").equals("SingleDouble")){
Element column3 = doc.createElement("column");
Element column4 = doc.createElement("column");
Element column5 = doc.createElement("column");
column3.setAttribute("index","3");
column4.setAttribute("index","4");
column5.setAttribute("index","5");
LinkedList l1=new LinkedList();
LinkedList l2=new LinkedList();
LinkedList all=new LinkedList();
List column0Tools=(List)context.get("pageColumn0Tools");
List column1Tools=(List)context.get("pageColumn1Tools");
if(column0Tools !=null){
l1.add(column0Tools.get(0));
column3.appendChild(createColumnToolsXml(doc,l1, page));
column0Tools.remove(0);
if(column0Tools !=null)
{
all.addAll(column0Tools);
}
columns.appendChild(column3);
if(column1Tools !=null && column1Tools.size()>0 )
{ l2.add(column1Tools.get(0)); column4.appendChild(createColumnToolsXml(doc,l2, page));
column1Tools.remove(0);
if(column1Tools !=null){
all.addAll(column1Tools);
}
}
columns.appendChild(column4);
if(all !=null){
column5.appendChild(createColumnToolsXml(doc,all, page));
}
columns.appendChild(column5);
}
Osp-Portal
osp-portal.xsl: -
将以下内容添加到portal.xslt和osp-portal.xsl
中<!--
===============match single and Double============
process a selected page with two column layouts
param:content - "true" or "false" if rendering tool content or tool list
=========================================================
-->
<xsl:template match="page[@layout='2' and @selected='true']">
<xsl:param name="content"/>
<xsl:if test="$content='true'">
<xsl:call-template name="page-content-custom">
<xsl:with-param name="page" select="."/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$content='false'">
<li>
<a accesskey="1" class="selected" href="#">
<xsl:attribute name="accesskey">
<xsl:value-of select="../../@order"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</li>
</xsl:if>
</xsl:template>
<!--Custom Sarath -->
<xsl:template name="page-content-custom">
<xsl:param name="page" />
<h1 class="skip">
<xsl:value-of select="$externalized/entry[@key='sit.contentshead']" />
</h1>
<a id="tocontent" class="skip" name="tocontent"></a>
<div id="content">
<div id="col1of2">
<div class="portlet">
<p class="pageId">$page</p>
<xsl:for-each select="$page/columns/column[@index='3']/tools/tool">
<xsl:call-template name="tool">
<xsl:with-param name="tool" select="." />
</xsl:call-template>
</xsl:for-each>
</div>
</div>
<div id="col2of2">
<div class="portlet">
<xsl:for-each select="$page/columns/column[@index='4']/tools/tool">
<xsl:call-template name="tool">
<xsl:with-param name="tool" select="." />
</xsl:call-template>
</xsl:for-each>
</div>
</div>
<div id="col1">
<div class="portlet">
<xsl:for-each select="$page/columns/column[@index='5']/tools/tool">
<xsl:call-template name="tool">
<xsl:with-param name="tool" select="." />
</xsl:call-template>
</xsl:for-each>
</div>
</div>
</div>
</xsl:template>
Portal.css 文件中的
#col1_new{
padding-right: .0em;
clear:both;
}
#col1of2_new{
width: 51%;
*/width: 48%;
float: left;
margin: 0;
margin-left: 0.3em;
}
#col2of2_new{
width: 48%;
*/width: 48%;
float: right;
}