Toby,

        Thanks for that...

I basically need a way to include a scripting into another script without executing it. Then, the amalgimation is executing. More like JSP's <@ page include /> then its <jsp:include>...

        Here's my dilemma:

I am building a series of admin pages for the repo content. They look somewhat different, but all have, at some point, a loop through their child nodes. The app directory is using various dirs to segregate the resourcetype views. The app dri looks like:

        /admin
                /genre
                /show
                /season
                /episode

        The content is more of a hierarchy:

                /content
                        /genre
                                /show
                                        /season
                                                /episode

For genre, show, and season, I need to loop through the child nodes of each parent. However, including wont work because if I include, say, genre/loop.jst (linked to the loop selector) for example in show, i'll still get genre's child nodes (including the show I'm actually on). I need to be able to reuse a script from another dir.

        -Josh

        


        
On Sep 17, 2008, at 12:59 PM, Tobias Bocanegra wrote:

hi josh,
one solution is to use another selector or resource type for your
included script.

eg:
/page
 page.jsp
 content.jsp

and in page.jsp you do:
<sling:include forceSelector="content" />
this will select the content.jsp as script when including 'this'
resource. the draw back of this is, that you 'destroy' any selectors
from the request, i.e. you can't propagate them into your content.jsp
without some manual magic.

another solution is using another resource type. eg:

/page
  page.jsp
  /content
     content.jsp

and in page.jsp you do:

<sling:include resourceType="page/content" />

you could even make this work 'relative' eg:

String rt = resource.getResourceType() + "/content";
<sling:include resourceType="<%= rt =>" />

regards, toby

ps: i wrote an extended include tag that allows direct execution of
other scripts without having an extra 'include'. this is somewhat
contradictory to the sling philosophy that tries to hide the
script-resolution-magic from the user by the paradigm that only
'resources' are included. imo, in some cases, you really know what you
do, and you want to execute/include a designated script.



On 9/17/08, Joshua Oransky <[EMAIL PROTECTED]> wrote:
Hello,

How can I statically include code from another script? That is, include it into execution in the context of the currentNode. Sling.include does not work for me, because it executes in the context of the included node. I have several instances where I need to reuse code in different visual layouts. It seems inefficient to write the same code over and over, and is a maintenance nightmare. I know there's the sling:superResourceType, but that doesn't really solve my issue, as I want to have reusable snippets.

       Thanks - Josh


Reply via email to