Current File in LP8.6

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

Current File in LP8.6

Steffan A. Cline
Having a case of cranial flatulence tonight doing some maintenance coding
on someone else's work.

I have a scenario like so:

Page A
        Includes Page B
                Includes Page C
                        Some Tag

Within "Some Tag" I need it to know the scope that it's operating in.

For example, "Some Tag" should know it's running in Page C.

Tinkering with local('currentFile' = response_filepath->split('/')->last);
that will return Page A and not Page C. Wasn't there a trick or tag for
that? It's late and perhaps I really am out of it.

No worries though. No Pilsonism tonight.

Ideas?



Thanks,
Steffan

---------------------------------------------------------------
T E L  6 0 2 . 7 9 3 . 0 0 1 4 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
Steffan A. Cline   [hidden email]
http://www.ExecuChoice.net                 Phoenix, Arizona USA
                 
---------------------------------------------------------------



#############################################################

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: Current File in LP8.6

stevepiercy
Didn't someone come up with a custom tag to do this?  Something like:

[include_filepaths('/path/to/file.inc')]

Then include_filepaths would take that argument, and both
include the file and insert its name into a variable of set
type.  This tag gets you partway there.
http://www.lassosoft.com/tagswap/detail/include_once

--steve


On 2/23/15 at 11:07 PM, [hidden email] (Steffan A. Cline) pronounced:

>Having a case of cranial flatulence tonight doing some maintenance coding
>on someone else's work.
>
>I have a scenario like so:
>
>Page A
>Includes Page B
>Includes Page C
>Some Tag
>
>Within "Some Tag" I need it to know the scope that it's operating in.
>
>For example, "Some Tag" should know it's running in Page C.
>
>Tinkering with local('currentFile' = response_filepath->split('/')->last);
>that will return Page A and not Page C. Wasn't there a trick or tag for
>that? It's late and perhaps I really am out of it.
>
>No worries though. No Pilsonism tonight.
>
>Ideas?
>
>
>
>Thanks,
>Steffan
>
>---------------------------------------------------------------
>T E L  6 0 2 . 7 9 3 . 0 0 1 4 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
>Steffan A. Cline              [hidden email]
>http://www.ExecuChoice.net                 Phoenix, Arizona USA
>
>---------------------------------------------------------------
>
>
>#############################################################
>
>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]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website 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: Current File in LP8.6

Ke Carlton-3
Yes, I think a custom approach is required in L8.x

On 24 February 2015 at 19:26, Steve Piercy - Website Builder <
[hidden email]> wrote:

Didn't someone come up with a custom tag to do this?

#############################################################

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: Current File in LP8.6

Bil Corry-3
In reply to this post by Steffan A. Cline
Try [include_currentpath].  I have a note that it doesn't work inside of
[process] or ctags, but that was from 2006.  Maybe it works now?

http://reference.lassosoft.com/LassoReference.LassoApp?%5BInclude_CurrentPath%5D


If it doesn't work, below is some code that can do it (from 2006), but read
the side effects in the comments.


- Bil


[

        define_atbegin: {
                // file currently being included
                var:'_lp_include_chain' = array;
                $_lp_include_chain->(insert: string); // top-level doesn't
call itself
                $_lp_include_chain->(insert: response_filepath);

        };

        define_tag:'include',
                -description='Overloads [include] so that the chain of
calls can be traced.',
                -priority='high',
                -required='_lp_filename',
                -optional='_lp_bypass',
                -criteria=(!local_defined:'_lp_bypass');

                /*
                         known side-effects of this overload, where the
behavior differs from the standard
                                (1) relative paths of includes are now from
the included file, not the original file called
                                (2) ctags defined via include in a ctag are
now scoped for the entire page, not just the scope of the tag
                */

                namespace_using:'_page_';  // make sure ctags defined are
available on the calling page

                        // make sure we pop the stack, even if there's an
error
                        handle: true;
                                $_lp_include_chain->remove;
                        /handle;

                        // normalize path from webroot
                        local:'_lp_include_file' = lp_file_absolutePath:
(string:#_lp_filename);

                        $_lp_include_chain->(insert: #_lp_include_file);
                        local:'_lp_return' = @(include:#_lp_include_file,-'
_lp_bypass');

                        // pass locals through to _page_
                        local:'_lp_locals' = locals;
                        #_lp_locals->(remove: '_lp_locals');
                        #_lp_locals->(remove: '_lp_filename');
                        #_lp_locals->(remove: '_lp_bypass');
                        #_lp_locals->(remove: '_lp_include_file');
                        #_lp_locals->(remove: '_lp_return');
                        vars->insertfrom(#_lp_locals->iterator);

                /namespace_using;

                return: @#_lp_return;
        /define_tag;

        define_tag:'lp_include_callingFile',
                -description='Returns the name of the file that included
the current file.  Returns empty string from top-level file.',
                -priority='replace';
                return: $_lp_include_chain->(get: $_lp_include_chain->size
- 1);
        /define_tag;

        define_tag:'lp_include_callingPath',
                -description='Returns the path of the file that included
the current file.  Returns response_path from top-level file.',
                -priority='replace';

                if: $_lp_include_chain->size == 2;
                        return: response_path;
                /if;

                local:'path' = $_lp_include_chain->(get:
$_lp_include_chain->size - 1)->(split:'/');
                #path->remove;
                return: #path->(join:'/') '/';
        /define_tag;

        define_tag:'lp_include_currentFile',
                -description='Returns the name of the current included
file.',
                -priority='replace';
                return: $_lp_include_chain->last;
        /define_tag;

        define_tag:'lp_include_currentPath',
                -description='Returns the path of the current included
file.',
                -priority='replace';

                local:'path' = $_lp_include_chain->last->(split:'/');
                #path->remove;
                return: #path->(join:'/') '/';
        /define_tag;

        define_tag:'lp_file_absolutePath',
                -description='Returns a path from web root given a relative
path.',
                -priority='replace',
                -required='filename';

                // is it already from webroot?
                if: #filename->(beginswith:'/');
                        return: #filename;
                /if;

                // ok, it's relative
                local:'path' = lp_include_currentPath->(split:'/');
                #path->remove;
                #path->(insert:  #filename);
                #path = #path->(join:'/');

                // are we done?
                if: !#path->(contains:'../');
                        return: #path;
                /if;

                // nope, got relative traversing going on
                // let's get rid of them...

                local:'return' = string;
                local:'previtem' = null;
                #path = #path->(split:'/');
                #path->(insert:'dummy value'); // extra value to make our
iterate cycle through all values
                iterate: #path, local:'loop_item';
                        if: #loop_item == '..' || #loop_item == null;
                                #previtem = null;
                        else: #previtem == null;
                                #previtem = #loop_item;
                        else;
                                #return += '/' #previtem;
                                #previtem = #loop_item;
                        /if;
                /iterate;

                return: @#return;
        /define_tag;

]




On Tue, Feb 24, 2015 at 7:07 AM, Steffan A. Cline <[hidden email]> wrote:

> Having a case of cranial flatulence tonight doing some maintenance coding
> on someone else's work.
>
> I have a scenario like so:
>
> Page A
>         Includes Page B
>                 Includes Page C
>                         Some Tag
>
> Within "Some Tag" I need it to know the scope that it's operating in.
>
> For example, "Some Tag" should know it's running in Page C.
>
> Tinkering with local('currentFile' = response_filepath->split('/')->last);
> that will return Page A and not Page C. Wasn't there a trick or tag for
> that? It's late and perhaps I really am out of it.
>
> No worries though. No Pilsonism tonight.
>
> Ideas?
>
>
>
> Thanks,
> Steffan
>
> ---------------------------------------------------------------
> T E L  6 0 2 . 7 9 3 . 0 0 1 4 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
> Steffan A. Cline                        [hidden email]
> http://www.ExecuChoice.net                 Phoenix, Arizona USA
>
> ---------------------------------------------------------------
>
>
>
> #############################################################
>
> 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: Current File in LP8.6

Jussi Hirvi-2
On 24.2.2015 10.40, Bil Corry wrote:
> Try [include_currentpath].

For example like this - run in the context of the included file:

   local('path') = include_currentpath -> split('/');
   #path -> last = '';
   local('mydir') = #path -> join('/'));

- 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]>