Announcement

Collapse
No announcement yet.

Pass Variable to readytheme function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Pass Variable to readytheme function

    Hi,

    I am trying to achieve some sort of automation with contentsection feature of readythemes. Basically, my idea is to have a variable and then add some numbers in front of that variable to get content sections in site front. I initially thought it to be something very simple, but now, I'm out of ideas.

    What I think it should be :

    Code:
    <mvt:item name="readytheme" param="contentsection( l.settings:myvar $ '-1' )" />
    Doesn't work at all.

    Other things that I tried although I knew might not work :

    Code:
    <mvt:item name="readytheme" param="contentsection( '&mvt:myvar;-1' )" />
    <mvt:item name="readytheme" param="contentsection( $ l.settings:myvar $ '-1' )" />
    <mvt:item name="readytheme" param="contentsection( '' $ l.settings:myvar $ '-1' )" />
    Any ideas how can I do this ?
    There is no other issue I can think of as when I try with hard-coding value, it works. When I mvt:eval this, it gives me exactly what I want in the contentsection function.
    Rajnish Sinha
    ---------------------
    https://twitter.com/rajnishsi

    #2
    Re: Pass Variable to readytheme function

    haven't played with ReadyTheme Content sections (just haven't had too) but try assigning the complete variable first before using it in the item. (Generally, an MVT item can't do expressions).

    For example,

    <mvt:assign name="g.thisVar" value="g.someValue $ '-1'" />
    <mvt:item name="readytheme" param="contentsection( g.thisVar )" />
    Bruce Golub
    Phosphor Media - "Your Success is our Business"

    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
    phosphormedia.com

    Comment


      #3
      Re: Pass Variable to readytheme function

      Thanks Bruce, I figured that a variable being passed to the function needs to be global, although I don't understand why ? If I am passing a local variable, it should work too, as my understanding of functions state that function will anyway create a local replica of that variable to process. So why does it matter whether I pass a local or a global variable ?
      Rajnish Sinha
      ---------------------
      https://twitter.com/rajnishsi

      Comment


        #4
        Re: Pass Variable to readytheme function

        Its not a local verses global. Its that parameters in SMT items generally cannot be expressions. (i.e., "l.var + 1" ).

        Global verses Local in SMT templates is the same as for general coding.
        Bruce Golub
        Phosphor Media - "Your Success is our Business"

        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
        phosphormedia.com

        Comment


          #5
          Re: Pass Variable to readytheme function

          Originally posted by Bruce - PhosphorMedia View Post
          Its not a local verses global. Its that parameters in SMT items generally cannot be expressions. (i.e., "l.var + 1" ).

          Global verses Local in SMT templates is the same as for general coding.
          Okay, I think I'm a little lost somewhere, when I use,
          Code:
          <mvt:assign name="g.meganav" value="'CONTENT'" />
          <mvt:item name="readytheme" param="contentsection(  g.meganav $ '-1' )" />
          It works, but when I use this,
          Code:
          <mvt:assign name="l.meganav" value="'CONTENT'" />
          <mvt:item name="readytheme" param="contentsection(  l.meganav $ '-1' )" />
          it doesn't. That's how I concluded that only global variables can be passed. Expressions don't seem to create any problem in there.
          Rajnish Sinha
          ---------------------
          https://twitter.com/rajnishsi

          Comment


            #6
            Re: Pass Variable to readytheme function

            Ah, I see...

            The problem is, g.meganav and l.maganav are passed to the back end of Miva as 'literal' values. So, the back end has doesn't have a variable called l.maganav. If you created it like l.settings:maganav it would probably work...but, typically I think folks DO use globals when calling back into the backend. I'd also still recommend doing an assignment first and removing the function in the parameter call--just as a good habit.
            Bruce Golub
            Phosphor Media - "Your Success is our Business"

            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
            phosphormedia.com

            Comment


              #7
              Re: Pass Variable to readytheme function

              Originally posted by Bruce - PhosphorMedia View Post
              I'd also still recommend doing an assignment first and removing the function in the parameter call--just as a good habit.
              Yeah, I think you are right about this, It will save a lot of debugging time in other functions where expressions are not supported. I'll keep it in mind. thanks.
              Rajnish Sinha
              ---------------------
              https://twitter.com/rajnishsi

              Comment

              Working...
              X