Tag priority, L8.5

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Tag priority, L8.5

Jussi Hirvi-2
I have never got tag priorities to work as expected, when the tags are
inside a custom type.

Practical case: My cross-site navigation system uses a custom type to
retrieve pages & categories from the db:
        var('mynavig') = MY_navigtype;
To get html code for the main menu:
        $mynavig -> menu;

Now I would like to override this in my liblocal.inc file, which wiill
never be overwritten when I upgrade the basic site code.

Here is a simple test code to show what I mean - BUT IT DOES NOT WORK.

in library.inc (the cross-site library):

define_type('navig',-namespace='MO');
(...)
         define_tag('menu',-priority='low');
           return('low priority');
         /define_tag;
/define_type;

in liblocal.inc (the local library):

define_type('navig',-namespace='MO');
(...)
         define_tag('menu',-priority='replace');
           return('replace-priority');
         /define_tag;
/define_type;

Is this possible - and if so, how?

- Jussi

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Ke Carlton-3
Always use -priority = 'replace' and add it to your define_type params, ie.

define_type('navig',-namespace='MO', -priority = 'replace');


You methods reside in the type — so you need to replace the type....

IMO anything other than 'replace' is confusing and should be dropped.

Ke


On 19 December 2013 16:19, Jussi Hirvi <[hidden email]> wrote:

> I have never got tag priorities to work as expected, when the tags are
> inside a custom type.
>
> Practical case: My cross-site navigation system uses a custom type to
> retrieve pages & categories from the db:
>         var('mynavig') = MY_navigtype;
> To get html code for the main menu:
>         $mynavig -> menu;
>
> Now I would like to override this in my liblocal.inc file, which wiill
> never be overwritten when I upgrade the basic site code.
>
> Here is a simple test code to show what I mean - BUT IT DOES NOT WORK.
>
> in library.inc (the cross-site library):
>
> define_type('navig',-namespace='MO');
> (...)
>         define_tag('menu',-priority='low');
>           return('low priority');
>         /define_tag;
> /define_type;
>
> in liblocal.inc (the local library):
>
> define_type('navig',-namespace='MO');
> (...)
>         define_tag('menu',-priority='replace');
>           return('replace-priority');
>         /define_tag;
> /define_type;
>
> Is this possible - and if so, how?
>
> - Jussi
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
On 19.12.2013 18.23, Ke Carlton wrote:
> Always use -priority = 'replace' and add it to your define_type params, ie.
>
> define_type('navig',-namespace='MO', -priority = 'replace');
>
>
> You methods reside in the type — so you need to replace the type....
>
> IMO anything other than 'replace' is confusing and should be dropped.

Ok, I tried that too, but I cannot get it to work.

define_type('mytype',-priority='replace');
         define_tag('mytag');
           return('replace-priority');
         /define_tag;
/define_type;
define_type('mytype');
         define_tag('mytag');
           return('default priority');
         /define_tag;
/define_type;

var('x') = mytype;
$x -> mytag;

This code triggers the default priority version. If I change the order
of the types, the replace-priority version is returned. So only the
order of the type versions seems to be significant.

What am I doing wrong?

- Jussi

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Ke Carlton-3
Well, you're redefining the type — why would you expect it to return
anything other than 'default priority' ?

From the docs:

"-priority Requires the value 'High', 'Low', or 'Replace'. Specifies
whether the tag should replace an existing tag with the same name or be
placed before or after existing tags in the calling chain. Optional."


Simply always use -priority = 'replace' and expect the definition to be
replaced (iirc this is particularly important when using global name
spaces). It will also help when you migrate to L9 as everything is replaced
by default.

IMO you're adding unncessary complexity for zero gain.

Ke




On 19 December 2013 16:44, Jussi Hirvi <[hidden email]> wrote:

>
> What am I doing wrong?
>
>
> - Jussi
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
On 19.12.2013 19.11, Ke Carlton wrote:

> Well, you're redefining the type — why would you expect it to return
> anything other than 'default priority' ?
>
>>From the docs:
>
> "-priority Requires the value 'High', 'Low', or 'Replace'. Specifies
> whether the tag should replace an existing tag with the same name or be
> placed before or after existing tags in the calling chain. Optional."
>
>
> Simply always use -priority = 'replace' and expect the definition to be
> replaced (iirc this is particularly important when using global name
> spaces). It will also help when you migrate to L9 as everything is replaced
> by default.
>
> IMO you're adding unncessary complexity for zero gain.

Sorry, I still don't understand this. How can priority be meaningfully
used if not to replace another tag (or type) with same name?

I have read that part of the Language Guide. In the section on priority,
there is only an example of replacing a built-in tag. In that case too
the replacing and replaced tag both have the same name, just like in my
example (which does not work, though).

Could you please give me an example case of a right way to use priority?

- Jussi

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

stevepiercy
In reply to this post by Ke Carlton-3
Also:

    define_type('navig', -namespace='MO_', -priority='replace');

You need the trailing '_' in the namespace.

In Knop, the library file form.inc contains:

    define_type('form',
        'knop_base',
        -namespace='knop_');

and is called:

    knop_form('burp');

--steve


On 12/19/13 at 4:23 PM, [hidden email] (Ke Carlton) pronounced:

> Always use -priority = 'replace' and add it to your define_type params, ie.
>
> define_type('navig',-namespace='MO', -priority = 'replace');
>
>
> You methods reside in the type — so you need to replace the type....
>
> IMO anything other than 'replace' is confusing and should be dropped.
>
> Ke
>
>
> On 19 December 2013 16:19, Jussi Hirvi <[hidden email]> wrote:
>
> > I have never got tag priorities to work as expected, when the tags are
> > inside a custom type.
> >
> > Practical case: My cross-site navigation system uses a custom type to
> > retrieve pages & categories from the db:
> >         var('mynavig') = MY_navigtype;
> > To get html code for the main menu:
> >         $mynavig -> menu;
> >
> > Now I would like to override this in my liblocal.inc file, which wiill
> > never be overwritten when I upgrade the basic site code.
> >
> > Here is a simple test code to show what I mean - BUT IT DOES NOT WORK.
> >
> > in library.inc (the cross-site library):
> >
> > define_type('navig',-namespace='MO');
> > (...)
> >         define_tag('menu',-priority='low');
> >           return('low priority');
> >         /define_tag;
> > /define_type;
> >
> > in liblocal.inc (the local library):
> >
> > define_type('navig',-namespace='MO');
> > (...)
> >         define_tag('menu',-priority='replace');
> >           return('replace-priority');
> >         /define_tag;
> > /define_type;
> >
> > Is this possible - and if so, how?
> >
> > - Jussi
> >
> > #############################################################
> > This message is sent to you because you are subscribed to
> >  the mailing list Lasso
> > [hidden email]
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
> >
>
> #############################################################
> This message is sent to you because you are subscribed to
>   the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Ke Carlton-3
In reply to this post by Jussi Hirvi-2
My overall point is not to use a prority low / high approach — simply
replace existing definitions or use alternative names. Programming is
already complicated enough without being uncertain about which method or
type is being called.

I no longer use Lasso 8.x — if I did I wouldn't use low or high (only
replace).

Although I imagine it works something like this:

define_tag('test',-priority = 'high');
    return('high');
/define_tag;

define_tag('test',-priority = 'low');
    return('low');
/define_tag;

test; // should be high — not that it matters.


Ke

On 19 December 2013 20:24, Jussi Hirvi <[hidden email]> wrote:

>
> Could you please give me an example case of a right way to use priority?
>
> - Jussi
>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
In reply to this post by stevepiercy
On 19.12.2013 22.36, Steve Piercy - Web Site Builder wrote:
> Also:
>
>      define_type('navig', -namespace='MO_', -priority='replace');
>
> You need the trailing '_' in the namespace.

Ok, interesting. For some reason I have always specified namespace
without underscore, like

        define_type('navig', -namespace='MO');

And I call it with MO_navig. It works in L8.5 and 9.1.4.

I see that underscore is used in the L8.5 docs, but not explained (or I
didn't find it).

Seems that underscore in the tag name does not work. For example calling
this tag:

        define_type('my_navig', -namespace='MO');

with MO_my_navig would not work. No wonder, actually.

- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
In reply to this post by Ke Carlton-3
On 19.12.2013 22.42, Ke Carlton wrote:

> Although I imagine it works something like this:
>
> define_tag('test',-priority = 'high');
>      return('high');
> /define_tag;
>
> define_tag('test',-priority = 'low');
>      return('low');
> /define_tag;
>
> test; // should be high — not that it matters.

Looks perfectly right to me. So it works with tags but not types? I
would say your example above is about identical with my type example
(which does not work).

Do you think that replacing a tag with another one somehow makes more
sense than replacing a type with another one? I don't see a reason to
think that way.

- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

stevepiercy
In reply to this post by Jussi Hirvi-2
On 12/19/13 at 10:57 PM, [hidden email] (Jussi Hirvi) pronounced:

>On 19.12.2013 22.36, Steve Piercy - Web Site Builder wrote:
>>Also:
>>
>>define_type('navig', -namespace='MO_', -priority='replace');
>>
>>You need the trailing '_' in the namespace.
>
>Ok, interesting. For some reason I have always specified
>namespace without underscore, like
>
>define_type('navig', -namespace='MO');
>
>And I call it with MO_navig. It works in L8.5 and 9.1.4.
>
>I see that underscore is used in the L8.5 docs, but not
>explained (or I didn't find it).
>
>Seems that underscore in the tag name does not work. For example calling this tag:
>
>define_type('my_navig', -namespace='MO');
>
>with MO_my_navig would not work. No wonder, actually.

Don't put _ in your type or tag names when using namespaces.  
Just like -priority, it adds unnecessary complexity.

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
On 19.12.2013 23.01, Steve Piercy - Web Site Builder wrote:
>> Seems that underscore in the tag name does not work. For example
>> calling this tag:
>>
>> define_type('my_navig', -namespace='MO');
>>
>> with MO_my_navig would not work. No wonder, actually.
>
> Don't put _ in your type or tag names when using namespaces. Just like
> -priority, it adds unnecessary complexity.

It's not just unnecessary complexity - underscorse simply don't work.
Which is fine. I use camel case instead.

- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
In reply to this post by stevepiercy
Ok, I found a simple way round this issue (it is an issue to me at
least). I am going to build this kind of structure to my cross-site
library. Then I can activate a bootstrappified version of a tag simply
by defining $bootstrap-site in my bootstrap site config.

define_type('navig',-namespace='LO_');
     if(variable_defined('bootstrap_site'));
         define_tag('mytag');
           return('bootstrap version of tag');
         /define_tag;
     else;
         define_tag('mytag');
           return('non-bootstrap version of tag');
         /define_tag;
     /if;
/define_type;

// comment the following line out to change behavior
var('bootstrap_site') = 'yes';

var('x') = LO_navig;
$x -> mytag;


- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Ke Carlton-3
This is really bad design.

The variable will only be considered on definition of the type — so unless
you're redefining your types on every page (also really bad) this is
seriously flawed.

A better way to approach your problem is with inheritance:

define_type('bootstrapnavi','LO_navig',-priority = 'replace');
    define_tag('mytag');
          return('bootstrap version of tag');
    /define_tag;
/define_type;

var('bootstrap_site') = true;

var('navi') = $bootstrap_site ? bootstrapnavi | LO_navig;



Also, I highly recommend you investigate the global namespace — it makes
developement in Lasso 8.5 so much easier and more productive. It's been a
while since I've touched it, but essentially you can do this:

namespace_using(namespace_global);
     define_type('this_is_available_site_wide_now');
     /define_type;
/namespace_using;


It sounds like you're doing quite a bit of new work with L8.6, it might be
a good opportunity to do some of this in L9 — it's much more straight
forward in regard.

Ke

tags: #inheritance #namespaces



On 20 December 2013 10:49, Jussi Hirvi <[hidden email]> wrote:

> Ok, I found a simple way round this issue (it is an issue to me at least).
> I am going to build this kind of structure to my cross-site library. Then I
> can activate a bootstrappified version of a tag simply by defining
> $bootstrap-site in my bootstrap site config.
>
> define_type('navig',-namespace='LO_');
>     if(variable_defined('bootstrap_site'));
>         define_tag('mytag');
>           return('bootstrap version of tag');
>         /define_tag;
>     else;
>         define_tag('mytag');
>           return('non-bootstrap version of tag');
>         /define_tag;
>     /if;
> /define_type;
>
> // comment the following line out to change behavior
> var('bootstrap_site') = 'yes';
>
> var('x') = LO_navig;
> $x -> mytag;
>
>
> - Jussi
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
>
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

stevepiercy
In reply to this post by Jussi Hirvi-2
On 12/20/13 at 11:50 AM, [hidden email] (Jussi Hirvi) pronounced:

>On 19.12.2013 23.01, Steve Piercy - Web Site Builder wrote:
>>>Seems that underscore in the tag name does not work. For example
>>>calling this tag:
>>>
>>>define_type('my_navig', -namespace='MO');
>>>
>>>with MO_my_navig would not work. No wonder, actually.
>>
>>Don't put _ in your type or tag names when using namespaces. Just like
>>-priority, it adds unnecessary complexity.
>
>It's not just unnecessary complexity - underscorse simply don't
>work. Which is fine. I use camel case instead.

MOOSE HAIR, I SAY!

define_type('moose_hair', -namespace='very_');
     local('critter');
     define_tag('hair', -required='critter');
         return('Very Hairy '+#critter+'!');
     /define_tag;
/define_type;

namespace_using('very_');
     local('m') = moose_hair;
     local('g') = moose_hair;
     local('j') = moose_hair;
     #m->hair('Moosie');
     '\n';
     #g->hair('Goosie');
     '\n';
     #j->hair('Jussi');
/namespace_using;

=>
Very Hairy Moosie!
Very Hairy Goosie!
Very Hairy Jussi!

But that's cheating.  ;)

Yet you can use _ for tag names within types.

[
// put in libraries
define_type('hairy', -namespace='very_');
     local('critter');
     define_tag('genus_species', -required='critter');
         return('Very Hairy '+#critter+'!');
     /define_tag;
/define_type;
]

[
// put in webroot
local('m') = very_hairy;
#m->genus_species('Moosie');
]
=> Very Hairy Moosie!

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
In reply to this post by Ke Carlton-3
On 20.12.2013 13.14, Ke Carlton wrote:
> It sounds like you're doing quite a bit of new work with L8.6, it might be
> a good opportunity to do some of this in L9 — it's much more straight
> forward in regard.

Not really new work, just trying to adapt my old cross-site code to a
new, different site. I know my code example was brutal. :-)

Thanks for excellent ideas, I will investigate inheritance and global
namespace. High time.

- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Tag priority, L8.5

Jussi Hirvi-2
In reply to this post by stevepiercy
On 20.12.2013 13.39, Steve Piercy - Web Site Builder wrote:
> => Very Hairy Moosie!

I need to get a haircut.

Happy Boxing Day!
- Jussi
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>