• No results found

Lesson #9 at a glance

&useWeblinkUrl

&webLinkClass

&fullLink

Welcome to lesson #9!

In this lesson we are going to be dealing with 3 parameters that influence how Wayfinder outputs links.

The &useWeblinkUrl parameter

By now you probably know that in MODx you can create two types of documents; "normal"

documents and documents that are weblinks. The &useWeblinkUrl parameter is concerned with weblinks. This parameter only accepts the Boolean values "TRUE" or "FALSE" and is set to "TRUE" by default. When creating a weblink document, you have to enter a URL that you wish that document to reference, i.e. the weblink. At the same time, MODx will add this document to your document tree and also assign it an id. If this document is included in your menu item, clicking it will take you to the URL you entered as the weblink. By default, Wayfinder will output the link you specified in the weblink instead of the normal MODx document link. For instance, if your weblink was specified as http://www.google.co.uk, this is what Wayfinder will output instead of that document's id.

However, using this parameter, you can instruct Wayfinder to output that documents MODx link instead. Note though that clicking on that document in the Wayfinder menu will still take you to the URL you specified as the weblink. Therefore, the only difference in setting the

&useWeblinkUrl parameter to "FALSE" is that the link will be shown as a MODx document link whilst clicking on the menu item will take the user to the correct and intended weblink. This is easier to understand if you see an example so let us create a weblink document.

Create a new weblink document and fill in the necessary fields. The images below illustrate the steps I followed and the output with this parameter not declared, i.e. letting Wayfinder use its default value.

Creating the weblink

82 The

weblink settings

Weblink created

Weblink in Wayfinder menu

Weblink in Wayfinder menu source code

Now set the parameter to "FALSE" as follows

83

[[Wayfinder? &startId=`0` &outerTpl=`menuContainer` &rowTpl=`menuRows` &level=`2`

&hideSubMenus=`TRUE` &useWeblinkUrl =`FALSE`]]

Preview the results; clicking on the menu item for the weblink document will still take you to the correct URL, Google UK in my case. However, look at the source code. You will see that Wayfinder has output the document's normal MODx link instead. Magic, eh?

The &webLinkClass class name parameter

As the name suggests, the &webLinkClass will be applied to all documents that are weblinks in the menu output by Wayfinder. There is no default value for this parameter so to use it you will have to specify it in the Wayfinder call. Let us see how this works. Modify the Wayfinder call as follows:

[[Wayfinder? &startId=`0` &outerTpl=`menuContainer` &rowTpl=`menuRows` &level=`2`

&hideSubMenus=`TRUE` &webLinkClass=`weblinks`]]

In the above example, I have assigned the value "weblinks" to my &webLinkClass parameter. You will obviously need to create some CSS rules for this class if you wish to style the weblinks differently from the "normal" menu items. The output of the above call results in the following source code with respect to the weblink menu item:

The &fullLink parameter

If this parameter is set to "TRUE", Wayfinder will output the full URL of the menu items instead of the relative URL. The default value is "FALSE". Have a look at the source code of the menu items. You

84

will notice that they are all relative, e.g. for the menu item "About", the URL is "/velito/about.html".

Yours could be different depending on whether you are using friendly URLs or not, etc.

To test this parameter, modify the Wayfinder call as follows:

[[Wayfinder? &startId=`0` &outerTpl=`menuContainer` &rowTpl=`menuRows` &level=`2`

&hideSubMenus=`TRUE` &fullLink=`TRUE`]]

The following is the resultant source code generated by Wayfinder for our Restaurant's website when &fullLink is set to "TRUE"

That is all for this lesson. In the next lesson we will look at some more uses of MODx document fields within Wayfinder. We will also look at how we can incorporate MODx Template Variables (TVs) within Wayfinder calls.

Before we wrap up, here is a brief recap of what we covered in this lesson

Summary of lesson #9

85

1. When set to "FALSE" the &useWeblinkUrl parameter will output the MODx link of a weblink document rather than the weblink URL itself. Clicking on such menu items, however, will still take the user to the correct and intended weblink URL.

2. The &webLinkClass class name parameter can be used to apply a specified class for all menu items that are weblinks rather than "normal" MODx documents. This would enable the application of CSS rules to specifically target menu items that are weblinks.

3. Wayfinder will normally output relative links of the menu items. By setting the parameter

&fullLink to "TRUE" you instruct Wayfinder to output the full URLs of the menu items. The default value is "FALSE"

See you in the next lesson!

86