Theming 101: Getting Some User Page Variables

December 22, 2011 By Aaron Delani

Liferay themes may cover or manage different aspects of a site. It can serve as the look and feel of the internal portal, external facing site, or a user's private and public pages. In this post, I'd like to quickly show you how to find out whether or not your theme is on a user-owned page. In the Liferay 6x plugin sdk, we'll use the $page_group variable to figure out the layout context we're using the theme in. So, from within init_custom.vm I'll write out some variables:

	#set ($is_current_users_page = $page_group.isUser() && ($page_group.getClassPK() == $user_id)) #set ($is_profile_page = $page_group.isUser() && !$layout.getPrivateLayout()) #set ($is_user_owned = $is_current_users_page || $is_profile_page)

We can use these variables within a theme interchangably, to be able to have certain theme elements available to users. Another quick tip: if you are looking into building profile pages, being able to get the current user that page belongs to.

 #set ($user_local_service = $serviceLocator.findService("com.liferay.portal.service.UserLocalService")) #set ($current_user = $user_local_service.getUserById($page_group.getClassPK())) #set ($current_user_name = $current_user.getFullName()) #set ($current_user_profile_url = $theme_display.getURLPortal() + $theme_display.getPathFriendlyURLPublic() + "/" + $current_user.getScreenName()) #set ($current_user_profile_portrait_url = $current_user.getPortraitURL($themeDisplay)) 

Theming 101: Sub-navigation dropdown blues

June 25, 2010 By Aaron Delani

We've seen this design before, navigation links that somehow bare children that you're able to play with in the comfort of the navigation's "lawn." Now don't get me wrong, there's really no perfect analogy for how simple and efficient dropdowns can be, it's just straightforward fun navigation.

While designing a theme for Liferay, you've probably wondered to yourself, "How easy would it be to actually implement this." Then maybe, you've drifted into the sub-navigation blues... well take it easy, maybe even get your Liferay plugin's sdk out and make some sub-navigation dropdowns with me:

Recently, I've been showing interns how to build drop down navigation items within Liferay themes. I think this information might be useful for those with the "sub-navigation blues."

To start, I developed this on Liferay 5.2 EE SP2, the jQuery javascript should work up to the latest version below 6.0

Building web interface usually involves html, which in our case, we're using Velocity to render html. Velocity is simple templating language developed by Apache. Then we also have the CSS and Javascript to format our sub-navigation visually and functionally.

Our journey starts within the theme:

In my navigation.vm file within the templates folder, Liferay 5.2 includes the for-loop I need in order to get the first child of the current iteration of the navigation item... it starts with a:

#if ($nav_item.hasChildren())

    #foreach ($nav_child in $nav_item.getChildren()) #if ($nav_child.isSelected()) #set ($nav_child_class = "selected") #else #set ($nav_child_class = "") #end
  • $nav_child.getName()
  • #end
#end

 

You can actually inspect the html and find that the child menu is just hidden with plain css. This is controlled through the navigation.css, within the CSS folder. To override this attribute, we'll change the state from within custom.css:

#navigation li:hover .child-menu, .ie6 #navigation li.hover .child-menu { display: block; }

You must be wondering why there's two selectors. To render the hover state in Internet Explorer 6, I needed to use javascript in order to specify the list item's hover state.

Here's some of the code for the actual child menu and the list item that holds it.

#navigation ul li { position: relative } #navigation .child-menu { background: #FFF; border: 1px solid #CCC; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; box-shadow: 0px 0px 13px #999; -moz-box-shadow: 0px 0px 13px #999; -webkit-box-shadow: 0px 0px 13px #999; left: 0; margin: 0; padding: 3px 0; position: absolute; top: 35px; width: 210px; z-index: 2; }

So in the end, there's just about 378 lines of formatted CSS (5.83kb), and 2 other edited files (navigation.vm 1.52kb and javascript.js 864bytes)... the 4 images came down to 16.3kb for all of them.

Download the theme and check out the code and play around with it. It's not a perfect or production quality theme, but it's a good way to explore how to make sub-navigation dropdowns.

Theming 101: Keeping it Within "custom.css"

March 5, 2010 By Aaron Delani

I've been playing around with theming on the new Liferay 6.0, from what I've noticed (theming side)- not much has changed, we're still using most of the same effective processes that we've had since 5.2.3. So, while I'm at it, I wanted to share with you, how I build themes on Liferay 6.0.

I usually start with something simple. I take into account, not knowing what everyone needs, but what everyone is accustomed to. So let's say for example, not all users have the same logo size, so I don't build anything too restrictive to that. I want to make sure I design something that's easy to understand and has a familiar layout.

The goal is to reach as wide an audience as possible. The users I'm intending to target need to be able to understand the information that's on the portal. I like to think of this as straightforward design.

So this first blog post, in this series of blogposts, in this post I'll be focusing on design and some strategies I use.

This is the first iteration of a theme I'll call "Slate."

I designed this really simple theme in Photoshop. It's just really simple; I haven't hashed out all the pages that a theme like this could have... but for now I'd just like to keep this simple.

It all starts out with creating the theme in my Plugins SDK environment. This way, I'll be able to make sure my theme has all that it needs in order to display all the new Liferay and Alloy UI components it needs.

The theme I've created looks pretty bare for now, it's an un-styled version of classic. It only inherits things necessary to properly display portlets and other functioning items such as the new Dockbar. Theming in Liferay 6.0 gives me much more control over the whole theme. Even the CSS normalizer is so unintrusive, it enables me to design with more prescision and less dependencies on Liferay's CSS.

I usually start out by blocking out all the elements:

You're probably wondering, what did I do the past 14 minutes? I was looking through the design and structure of the theme, what html elements came after another, then just went on and styled each that I discerned was necessary. I kept all the styling really simple. The goal was to create a simple visual representation of what I want to accomplish. I like to think of this as a preliminary sketch an artist draws. It's like a soft brush stroke or a light pencil mark. Hmm, I guess I'll call this stage of theming for me a: "CSS Sketch"

While dealing with the CSS for this, I like to think of better ways to both consolidate code and make the CSS easier to read. For example:

#navigation {
	background: #333;
	height: 32px;
	padding: 0 10px;
}

#navigation ul,
#navigation ul li,
.site-breadcrumbs .breadcrumbs,
.site-breadcrumbs .breadcrumbs li {
	list-style-type: none;
	margin: 0;
	padding: 0;
}

#navigation ul li,
.site-breadcrumbs .breadcrumbs li {
	display: inline-block;
	float: left;
}

#navigation ul li a {
	color: #FFF;
	display: inline-block;
	height: 32px;
	line-height: 32px;
	padding: 0 10px;
	text-decoration: none;
}

I hope you notice from this example that "#navigation" comes before "#navigation ul," and "#navigation ul" comes before "#navigation ul li." I style from the topmost element then later target the more specific children elements if needed. This way, I code less and do more.

#navigation ul,
#navigation ul li,
.site-breadcrumbs .breadcrumbs,
.site-breadcrumbs .breadcrumbs li {
	list-style-type: none;
	margin: 0;
	padding: 0;
}

The reason why I've consolidated so many selectors within the second set of properties is because these are really generic properties and values that I can re-use over and over again.

The last part is alphabetized properties and consistent code formatting. I always try my best to alphabetize my properties, it's easier to read, sort-through and deal with. The way the code is formatted is first, the selector then single tabbed line-breaks and a space after, then properties. I try to make it as consistent as possible because I never know when I'm going to need to do a regex to find and replace multiple properties.

I was able to block out everything I saw fit with 87 lines of code, I kept it simple enough and tested it in IE6-8, Firefox 3.6 and Chrome 5.0+, and it works just great. All this was achieved while keeping it within "custom.css"

Well, that's it for now in this series. In the next blog-post, I'll be writing about CSS sprites and graphic strategies I use when rationalizing sprites.

Building Content...

February 17, 2010 By Aaron Delani

So recently, I was tasked to create a few themes... whenever I style themes, I always think about web content. I cant help but to be impressed with the possibilities of web content in Liferay. You wouldn't realize it, but, most of this site is built on web content. 

Because of Velocity we can build quick prototypes of portlets, or even build web content to take the place of a portlet. Each piece of web content can be tagged, categorized, given a template... all which leads to dynamic queries later on, and even be able to have the content display other content.

How have you used web content recently?

Portal, portal, all my web services together, reminds me of a portal

February 12, 2010 By Aaron Delani

I've known that this trend as a "Lifestream" or "Social Streaming." If you're like me, I have many different services that I'm subscribed to. For example, I have a Yahoo (Flickr), Google (Blogger + OpenID, Picasa, Gmail, Google Profile...), Tumblr, Facebook, AIM, Digg, Liferay (Woo Hoo), FriendFeed, LinkedIn, Friendster, and Twitter Account (just to name a few). It's complicated and the least I can say is that my friends and family can't even follow me, many of them are totally oblivious to RSS and ATOM feeds. They don't know what aggregators are. They are the long tail of the market. As I traverse on all these social networks, I find myself lurking within the chaos of social networking.

Now, I realize that this is the sound of a portal. Portals present information in a unified way. Here at Liferay, we use our forums, our email, our wikis, our document library, calendar, our blogs, chat portlet (sometimes), and the (user) directory... to communicate. I really see how tied in our portal is that social networking within our company. Most of everyone, the 100+ employees from all around the world, here at Liferay, actually talk to each other. I have to admit that much of it is from email, but dog food has never tasted so good as it does in Liferay.

When I compare how our portal allows us to work as a community, to why it is so essential for me to consolodate all my feeds and services into one stream... is that I want to communicate better. I want my friends and family to know what's happening in my life, even just glimpses of it. In my work, I want to be able to talk to my colleagues, let them know what I'm working on. The more companies communicate internally, the more we produce efficiently.

This all reminds me, I can't wait for the release of Liferay 6.0 with so many content management and communication improvements, it looks awesome(I've seen things), it is awesome!

Showing 1 - 5 of 9 results.
Items 5
of 2