You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Elif Guner <el...@gmail.com> on 2006/10/03 22:13:28 UTC

Re: How to get the parent div within a portlet?

Hi,

Is there a way to get the portlet fragment's parent and give it a
style dynamicaly within the portlet?
Such as: when I add a portlet it's put inside a <div> like : <div
class="portal-layout-cell portal-layout-cell-ThreeColumns-0-0" >
What I'd like to do is style this <div> within my portlet. As in, make
its style float:left, or clear: left etc.
Is this possible? I tried to use the ContentFragment but it doesn't
have a method to get the parent.
Any help?

Thanks,

Elif

On 9/29/06, Elif Guner <el...@gmail.com> wrote:
> Hi,
>
> Is there any way to get the parent div tag of the portlet? I want to
> set the style of that div tag dynamically inside my portlet.
>
> Thanks...
>
> Elif
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How to get the parent div within a portlet?

Posted by Elif Guner <el...@gmail.com>.
I just managed to do what I needed to do! I played with layout.vm file
and what I basically did was, if the fragment id = the big portlet's
id, then open a div tag and put the upcoming portlets within that div
and check the last portlet's id (that's supposed to be in the div) and
then if it's the last fragment close the div. The piece of code
opening up the div and closing it is:

<div id="column_${myFragment.getId()}_${columnIndex}"
class="portal-layout-column
portal-layout-column-${layoutType}-${columnIndex}"
style="float:${columnFloat}; width:${columnWidth};">

	     #foreach($f in $column)
  	
           ## Set up coordinates for this fragment
           #set($coords = $columnLayout.getCoordinate($f))	
           #set($col = $coords.x)
           #set($lastRow = $columnLayout.getLastRowNumber($col))
           #set($row = $coords.y)
	   ## if two portlets need to be enclosed within a div
           #if($putinonediv == "true")
              <div id="portletencloser" style="float:left";>
              <div class="portal-layout-cell
portal-layout-cell-${layoutType}-${row}-${col}" style="clear:left"; >
           #else
              ## get the decorated Portlet content
		   <div class="portal-layout-cell
portal-layout-cell-${layoutType}-${row}-${col}" >
           #end
    ...............  //here goes if ($editing) etc.
    #if($f.type == "portlet")
		     $jetspeed.setCurrentFragment($f)
                           #if($f.id == "oilgas-oilcontent")
                              #set($putinonediv = "true")
                           #else
                              #set($putinonediv = "false")
                           #end
			     #parse($f.decoration.template)
		   #else		
	 	 	 $jetspeed.setCurrentFragment($f)
  			 $f.renderedContent			
		   #end
		   </div>
                   #if($f.id == "oilgas-issue")
          		</div>
          	   #end
		 #end
	  </div>

	  #set ($columnIndex = $columnIndex + 1)
	#end
  </div>

Thanks a lot Jacek, your $f.id gave me the whole idea :)

Elif

On 10/4/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Elif Guner z 2006-10-04 18:46 brzmiala:
>
> > Thanks very much Jacek, that helps.
> > But I have another question that's a bit more complex. You know in
> > layout.vm every time you add a portlet into a column, it encloses it
> > within a div. I want to put two different portlets within one div.
> > That's one of the reasons I wanted to get the parent and then I was
> > gonna try to find out a way to include the portlet content within the
> > parent. To be more specific, what I want to do is, I have a 3 column
> > layout in a row. The middle column is 500px wide. I have a portlet
> > which is in a div that is 300px wide. I have two small portlets that
> > are 190 px wide. Now, my large portlet has more content so its height
> > is bigger than two small ones. What I'd like to do is, put the large
> > portlet in the column, and then put the small ones near it so that
> > large is on the left and 2 small next to it. But to do this, I need to
> > put two small ones in one div and make this div style float:left. And
> > the little portlets' own div syles will be clear:left. I got the
> > source html of the portal and changed the code to do this, to see if
> > it'd result the way I expected and yes it did.
> > So, this is what I was trying to do.
> > Thanks for your help...
> Well, your structure is rather complex, indeed. Some nested layout could
> help. Have you considered adding to Jetspeed your own layout?
>
> --
> pozdrawiam,
>      Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How to get the parent div within a portlet?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Elif Guner z 2006-10-04 18:46 brzmiala:

> Thanks very much Jacek, that helps.
> But I have another question that's a bit more complex. You know in
> layout.vm every time you add a portlet into a column, it encloses it
> within a div. I want to put two different portlets within one div.
> That's one of the reasons I wanted to get the parent and then I was
> gonna try to find out a way to include the portlet content within the
> parent. To be more specific, what I want to do is, I have a 3 column
> layout in a row. The middle column is 500px wide. I have a portlet
> which is in a div that is 300px wide. I have two small portlets that
> are 190 px wide. Now, my large portlet has more content so its height
> is bigger than two small ones. What I'd like to do is, put the large
> portlet in the column, and then put the small ones near it so that
> large is on the left and 2 small next to it. But to do this, I need to
> put two small ones in one div and make this div style float:left. And
> the little portlets' own div syles will be clear:left. I got the
> source html of the portal and changed the code to do this, to see if
> it'd result the way I expected and yes it did.
> So, this is what I was trying to do.
> Thanks for your help...
Well, your structure is rather complex, indeed. Some nested layout could 
help. Have you considered adding to Jetspeed your own layout?

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How to get the parent div within a portlet?

Posted by Elif Guner <el...@gmail.com>.
Thanks very much Jacek, that helps.
But I have another question that's a bit more complex. You know in
layout.vm every time you add a portlet into a column, it encloses it
within a div. I want to put two different portlets within one div.
That's one of the reasons I wanted to get the parent and then I was
gonna try to find out a way to include the portlet content within the
parent. To be more specific, what I want to do is, I have a 3 column
layout in a row. The middle column is 500px wide. I have a portlet
which is in a div that is 300px wide. I have two small portlets that
are 190 px wide. Now, my large portlet has more content so its height
is bigger than two small ones. What I'd like to do is, put the large
portlet in the column, and then put the small ones near it so that
large is on the left and 2 small next to it. But to do this, I need to
put two small ones in one div and make this div style float:left. And
the little portlets' own div syles will be clear:left. I got the
source html of the portal and changed the code to do this, to see if
it'd result the way I expected and yes it did.
So, this is what I was trying to do.
Thanks for your help...
Elif

On 10/3/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Elif Guner z 2006-10-04 02:52 brzmiala:
>
> > Yes but then it'll apply the style to all the columns that the frame
> > has. If I have a Velocity 3 columns and if i give id to a fragment and
> > change its style with js, it'll apply it to all of the 3 div's that
> > layout has. I want to apply it to a single one depending on where I
> > put my portlet.
> A decorator.vm contains:
>    ...
>    <div id="${f.id}" class="portlet ${decoration.baseCSSClass}">
>    ...
>
> Referring to a div with id="${f.id}" (it addresses a single fragment)
> should work. If not, envelope it with another div.
>
> --
> pozdrawiam,
>      Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How to get the parent div within a portlet?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Elif Guner z 2006-10-04 02:52 brzmiala:

> Yes but then it'll apply the style to all the columns that the frame
> has. If I have a Velocity 3 columns and if i give id to a fragment and
> change its style with js, it'll apply it to all of the 3 div's that
> layout has. I want to apply it to a single one depending on where I
> put my portlet.
A decorator.vm contains:
   ...
   <div id="${f.id}" class="portlet ${decoration.baseCSSClass}">
   ...

Referring to a div with id="${f.id}" (it addresses a single fragment) 
should work. If not, envelope it with another div.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How to get the parent div within a portlet?

Posted by Elif Guner <el...@gmail.com>.
Yes but then it'll apply the style to all the columns that the frame
has. If I have a Velocity 3 columns and if i give id to a fragment and
change its style with js, it'll apply it to all of the 3 div's that
layout has. I want to apply it to a single one depending on where I
put my portlet.

Elif

On 10/3/06, Jacek Wiślicki <ja...@gmail.com> wrote:
> Wiadomosc od Elif Guner z 2006-10-03 22:13 brzmiala:
>
> > Is there a way to get the portlet fragment's parent and give it a
> > style dynamicaly within the portlet?
> > Such as: when I add a portlet it's put inside a <div> like : <div
> > class="portal-layout-cell portal-layout-cell-ThreeColumns-0-0" >
> > What I'd like to do is style this <div> within my portlet. As in, make
> > its style float:left, or clear: left etc.
> > Is this possible? I tried to use the ContentFragment but it doesn't
> > have a method to get the parent.
> > Any help?
> Modify a portlet decorator and add some id attribute to a fragment's
> containing element (e.g. a fragment id in PSML). Then access this
> element with JavaScript (document.getElementById(...)) and modify its
> style.
>
> --
> pozdrawiam,
>      Jacek Wislicki
>
> jacek.wislicki@gmail.com
> http://www.nauka-biznes.org.pl/jetspeed/portal/
> tel.: +48 502 408 444
> gg: 2540358
> skype: jacek_wislicki
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: How to get the parent div within a portlet?

Posted by Jacek Wiślicki <ja...@gmail.com>.
Wiadomosc od Elif Guner z 2006-10-03 22:13 brzmiala:

> Is there a way to get the portlet fragment's parent and give it a
> style dynamicaly within the portlet?
> Such as: when I add a portlet it's put inside a <div> like : <div
> class="portal-layout-cell portal-layout-cell-ThreeColumns-0-0" >
> What I'd like to do is style this <div> within my portlet. As in, make
> its style float:left, or clear: left etc.
> Is this possible? I tried to use the ContentFragment but it doesn't
> have a method to get the parent.
> Any help?
Modify a portlet decorator and add some id attribute to a fragment's 
containing element (e.g. a fragment id in PSML). Then access this 
element with JavaScript (document.getElementById(...)) and modify its 
style.

-- 
pozdrawiam,
     Jacek Wislicki

jacek.wislicki@gmail.com
http://www.nauka-biznes.org.pl/jetspeed/portal/
tel.: +48 502 408 444
gg: 2540358
skype: jacek_wislicki

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org