Sakai Site page tools alignment

174 views Asked by At

i want to customize sakai site tool configuration like this format using layouts. but by default in sakai layout is possible by double layout or single layout. actually i need combination of both first row is double column layout and remaining single column layouts.

please tell me is there any option to do like this.or provide me guidance how to customize .here i am inserted image i want tool alignment like this

Thanks In Advance https://i.stack.imgur.com/Xjy17.png

site tool alignments

1

There are 1 answers

1
Sarath Babu Nuthimadugu On BEST ANSWER

finally its working i did this. Please provide any suggestions if required for more flexibility or any other way to do this.

Kernel

Sitepage.java :-

Add

public static final int LAYOUT_MY_CUSTOM = 2;

BaseSitepage.java:-

Change this in

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;  }

Portal:-

Comment following code in the method

 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");

and replace the code

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");
}

And change

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)

Site Manage:-

SiteAction.java

Add custom layout to following method 8990 line

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 Tool

XSltcharon portal:-

XsltrenderContext.java:-

Comment the following

/*pageElement.setAttribute("layout", (context.get("pageColumnLayout")
                    .equals("col1")) ? "0" : "1");*/

And replace with

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";
                }

And add following statements in 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:-

Add the following into portal.xslt and 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>

in Portal.css file

#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;
}