link alias

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

link alias

keith1y
Lukas,

I find on a regular basis that I want to be able to provide an alias  
to value "links", e.g. the following displays a link to the current  
structure, with the text "Login", executing the login command, and  
this link is only displayed if the user is not logged in.

+value:structure|link=Login|command=PULogin|loggedout+

This can be implemented very simply in PRValueLink>>#formatStructure:  
aStructure in: aContext

do let me know if you include this addition,

thanks in advance

Keith


=======
PRValueLink>>#formatStructure: aStructure in: aContext

        "Format ==aStructure==. Link it, if the parameter ==link== is given;  
embed it, if the paremeter ==embed== is given."
       
        | string |
        ((self selectAndReject: aStructure) isNil
                or: [ (aContext structure: aStructure) isValid not
                or: [ (aStructure propertyAt: #hideFromMenus ifAbsent: [ false ]) ] ])
                        ifTrue: [ ^ nil ].

"BEGIN MODIFICATION TO PROVIDE ALIAS TO LINK"
        string := self parameterAt: 'link'.
       
        string ifNil: [
                string := self
                        formatDescribed: aStructure
                        default: #title
        ].
"END MODIFICATION TO PROVIDE ALIAS TO LINK"

        ^ ((self hasParameter: 'link') or: [ self hasParameter: 'embed' ])
                ifTrue: [
                        PRInternalLink new
                                embedded: (self hasParameter: 'embed');
                                parameters: self parameters;
                                target: aStructure;
                                addAll: (string isNil
                                        ifTrue: [ Array new ]
                                        ifFalse: [ Array with: (PRText content: string) ]);
                                yourself ]
                ifFalse: [ string isNil ifFalse: [ PRText content: string ] ]
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki