• No se han encontrado resultados

Capítulo II. Aforo en flujos en lámina libre: estado del arte

2.3 Técnicas en desarrollo

2.3.3 El Perfilador de corrientes por efecto Doppler (ADCP)

Link to Page: Inserts a link to another page in the same community. Selection Break: Inserts a break in the content.

Editing Elements

When creating a new structure it is essential that you set the variable names for the elements for the tem- plate writers. Otherwise, the gener- ated variable names will be very diffi- cult for a template writer to follow. For Spartan Software, we want to cre- ate a series of guides that give a step- by-step list of instructions for the game level designers. In your struc- ture, you can add the element Text

Area (HTML) which has the Field Label Instructions. However, we want to give

it the variable name of Steps. This can

be done very easily: at the bottom of every form element is a Variable

Name field. Replace the generated

name with the name you want to use. There are many other options for fields, including setting tooltips for users. To set these options, select the

Edit Options button in the lower right

corner of the element.

The Instructions for the User field is where you can type in instruc-

as a tooltip. For the Spartan Software Company News structure, type in some- thing that will help users know what to put into the Body element (example: this is an HTML Text area for the body of your content). Also, enable the Dis- play as Tooltip box. Now, when users hover over the Help icon near your title, they will see the instructions you entered.

Assigning Permissions

Permissions to the structure are straightforward. Generally, you don't want most users editing structures as this often requires a developer to modify the template assigned to the structure. However, you do want to make your structure viewable to everyone that will be using it to add web content. You can determine who views a structure by selecting from the

Viewable By select box beneath the Permissions tab. By default the Anyone (Guest Role) is selected.

You will also want to determine how users can interact with the struc- ture. You can do this by selecting the More link.

From the More link, you have the ability to grant or deny permissions based on Roles. For instance, you can give the Guest role the ability to Add

Discussion or you may want to give a Community Member the ability to Delete.

Liferay Portal makes it easy to configure the permissions based on your spe- cific needs for the site.

Templates

Developers create templates to display the elements of the structure in the markup that they want. Content can then be styled properly using CSS, because markup is generated consistently when users enter content. In es- sence, templates are scripts that tell Liferay how to display the content with- in the fields determined by the structure. Any changes to the structure re-

Illustration 55: View Permissions for Structure

quire corresponding changes to the template. Otherwise, new or deleted fields will produce errors on the page. Without a template, the portal has no idea how to display content which has been created using a custom structure.

Template Types (VM, XSL, FTL, and CSS)

Liferay supports templates written in four different templating lan- guages. This is so that you can get started right away. If you have experience with one over another, you can use whichever one you've already used be- fore. If you are just starting with any one of them, we recommend Velocity, as it is less “chatty” than XSL and extremely simple to understand.

VM (Velocity Macro): Velocity is a scripting language that lets you mix

logic with HTML. This is similar to other scripting languages, such as PHP, that you may have seen before, though Velocity is much simpler. It's been in the product the longest, so it is probably the most widely used language for templates in Liferay CMS. If you haven't used any of the template languages before, we recommend using Velocity: you'll get up to speed the fastest.

XSL (Extensible Style Sheet Language): XSL is used in Liferay templates

to transform the underlying XML of a structure into markup suitable for the browser. While it may not be as clean and compact as Velocity or FTL, it is widely used for transforming XML into other formats.

FTL (FreeMarker Template Language): Freemarker is a templating lan-

guage which could be considered a successor to Velocity, though it is not yet as popular. It has some advantages over Velocity for which it sacrifices some simplicity, yet it is still easy to use and less “chatty” than XSL.

CSS (Cascading Style Sheets): You can use CSS if your structure is very

straightforward and modifications are simple (colors, fonts, layouts, etc). If your structure is more complex, however, you'll need to use one of the other options.

Adding a Template

Liferay CMS makes it easy to create structures, templates, and content from the same interface. Let's go through the entire flow of how we'd create a structure, link it to a template, and then create content based on what we've defined. We'll use Velocity for our template, and we'll lay out the structure fields systematically to go along with the format we've defined for our content.

1. Go back to the Web Content section of the Control Panel and click Add Web Content.

2. Select Edit from the Structure tab.

3. Remove the Content field and add the following fields:

Variable Name Field Type

Title Text

Abstract Text Box

Image Image Gallery

Body Text Area

4. Select Save.

5. After you have saved the structure, select the Templates tab. 6. Select Add Template.

7. Type in a name and description and enable the Autogenerate ID box.

8. De-select the box labeled Cacheable. 9. Select VM as the language.

10. If you've written the script beforehand, you can select Browse to upload it from your machine. Otherwise, you can click Launch

Editor to type the script directly into the small editor window

that appears. 11. Select Save.

12. Return to the Web Content tab and open the Company News content. You'll see the new element labeled Abstract just below the Title.

Below is the template script for this structure. It is written in Velocity: #set ($renderUrlMax = $request.get("render-url-maximized"))

#set ($namespace = $request.get("portlet-namespace")) #set($readmore = $request.get("parameters").get("read_more")) <h1>$title.getData()</h1> #if ($readmore) <p>$abstract.getData()</p> <p>$body.getData()</p> #else <p>

<img src="${image.getData()}" border="0" align="right"> $abstract.getData()</p>

<a href="${renderUrlMax}&${namespace}read_more=true">Read More</a> #end

This template is pretty small, but it actually does quite a bit. First, a port- let URL which maximizes the portlet is created. Once this is done, we get the namespace of the portlet. This is important because we don't want our URL to collide with another URL that might be on the page.

After this, we attempt to get a request parameter called read_more.

Whether or not we were successful in getting this parameter is the key to the rest of the script:

• If we were successful in getting the read_more parameter, we

display the abstract and the body below the title (which is al- ways displayed).

• If we were not successful in getting the read_more parameter,

we display the image, the abstract, and the link we created above, which sets the read_more parameter.

When this template is rendered, it looks something like this:

Of course, there is much, much more you can do with structures and templates. Check out the Liferay Wiki (http:// wiki .liferay.com) for further in- formation and examples.

Illustration 58: By default, the content displays like this. If the user clicks the Read More link, the portlet will display the body field as well. Note we've also

Assigning Template Permission

Permissions for templates are very similar to permissions for structures. Generally, you only want specific developers accessing the template. How- ever, you may want to make the templates viewable to some content creat- ors who understand the template scripting language, but are not directly writing the scripts. You can determine who views the template by selecting from the Viewable By select box beneath the Permissions tab. By default the

Anyone (Guest Role) is selected.

You'll also want to determine how users can interact with the template. You can do this by selecting the More link.

Illustration 59: View Permissions for Templates

From the More link, you have the ability to grant or deny permissions based on Roles. For instance, you may create a role with the ability to up- date the template and create a second role that can both update and delete. Liferay Portal makes it possible to assign permissions based on the roles and responsibilities within your organization.