value:structure|level - what does it mean?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

value:structure|level - what does it mean?

sergio_101-2
ran across these on the blog title page

<h1 class="heading">}}}*>value:structure|level=2*{{{</h1>
<h1>}}}*>value:structure|level=0|lower=3*{{{</h1>

can someone explain what level and lower are?

thanks!

--
----
peace,
sergio
photographer, journalist, visionary

http://www.CodingForHire.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: value:structure|level - what does it mean?

Nick
Hi Sergio,

ran across these on the blog title page

<h1 class="heading">}}}*>value:structure|level=2*{{{</h1>
<h1>}}}*>value:structure|level=0|lower=3*{{{</h1>

can someone explain what level and lower are?

A good question - I didn't know the answer myself so did some delving. I'll answer indirectly via the journey I took to find the answer.


value:structure - Display the current structure - but no help with parameters.

The object that holds value links is PRValueLink.
PRDocument elements are rendered using a visitor pattern [1]. By convention #accept: is the method that takes the visitor:

PRValueLink>>accept: aVisitor
aVisitor visitValueLink: self

so we look for all implementors of #visitValueLink: It looks like there are two possibilities PRReferenceRenderer and the default implementation in PRVisitor.

I set a conditional break-point in PRReferenceRenderer as:

self haltIf: ((aLink parameterAt: 'level' ifAbsent: []) notNil and: [ (aLink  parameterAt: 'lower' ifAbsent: []) notNil ]).

The break-point was hit and stepping through I end up in PRValueLink>>#lookupStructure:do:

which has the helpful comment:

Lookup aStructure and evaluate aBlock if it is found. This performs different kinds of navigation starting from aStructure. If the parameter path is given an absolute or relative lookup is started. The parameter level choses a structure at the specified level in the parent chain, where the root is 1 and direct children of the root 2, etc. 0 is the current structure, -1 the parent of the current structure, etc. Furthermore the levels can be delimited using lower and upper bounds

so:

 *>value:structure|level=0|lower=3*

means use the current structure (level=0) but only if the current structure is 3 or more levels down. Levels are defined as the number of parents e.g. a template displaying a blog entry at /pier/blog/downtobusiness would have 3 levels of parents.

What does it do with the structure? PRValueLink>>formatDescribed:default: is called. If a parameter "display" is defined it will try to find a description for the structure with a matching parameter. The default is #title. In this case there is no "display" parameter so the structure's title is displayed.

If you want to see what parameters could be displayed by say a blog post (magritte 3):

PBPost new magritteDescription children select: [:each | each parameterName notNil] thenCollect: [ :each | each parameterName ]

a SortedCollection('name' 'menu' 'title' 'tags' 'owner' 'group') 

The result of this is that when you display a blog post the title of the blog post is displayed so: http://localhost:8080/pier/blog/downtobusiness

Displays:

Blog
Down to business
I like blogging, so here is my second post.

Where "Down to business" is displayed by *>value:structure|level=0|lower=3*. 

Nick


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki