Announcement

Collapse
No announcement yet.

Is there a cleaner way to do this

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

    Is there a cleaner way to do this

    Hello everyone

    Is there a cleaner way of doing the following?

    Earlier in the script the variables g.query, g.rowid where populated and I now wish to reference them in a link so the link appears like this in the html...

    /profile.mvc?id=3 (3 being whatever the current record number is in the loop)

    However the following doesn't work as it causes compiler errors...

    <a href="/profile.mvc?id=<MvEVAL EXPR="{ g.query[g.rowid]:profile_id }">"><MvEVAL EXPR="{ g.query[g.rowid]:profile_name }"></a>

    The only way I can get it to work is this way...

    <MvEVAL EXPR="{ '\<a href\=\"/game\.mvc\?id\=' $ g.query[g.rowid]:profile_id $ '\"\>' $ g.query[g.rowid]:profile_name $ '\</a\>' }">

    I am sure there must be a cleaner way but I just can't see it. Any help would be much appreciated.

    #2
    Re: Is there a cleaner way to do this

    Code:
    <MvEval expr=“{ '<a href="/profile.mvc?id=‘ $ g.query[g.rowid]:profile_id  $ ‘“>’ $ g.query[g.rowid]:profile_name $ '"></a>’  }">
    Not checked, but I think its right
    William Gilligan - Orange Marmalade, Inc.
    www.OrangeMarmaladeinc.com

    Comment


      #3
      Re: Is there a cleaner way to do this

      Alternate:
      Code:
      <a href="{ '/profile.mvc?id=' $ g.query[g.rowid]:profile_id }"><MvEVAL EXPR="{ g.query[g.rowid]:profile_name }"></a>
      
      Pretty much anywhere HTML has a quoted value inside a tag, if you use the curly braces, it becomes an implied MvEVAL. So you could have things like:
      Code:
      <input type="text" name="{ l.name }" id="{ 'id_' $ l.name }" value="{ encodeentities( l.value ) }" />

      Comment


        #4
        Re: Is there a cleaner way to do this

        Originally posted by Scott McCollough View Post
        Pretty much anywhere HTML has a quoted value inside a tag, if you use the curly braces, it becomes an implied MvEVAL. So you could have things like:
        Code:
        <input type="text" name="{ l.name }" id="{ 'id_' $ l.name }" value="{ encodeentities( l.value ) }" />
        :-O Wait...wut? Goodness me that is a uber useful thing to know. My code looks so much cleaner now LOL. Thank you for your assistance.

        Comment


          #5
          Re: Is there a cleaner way to do this

          Yea, there a lot of little "tricks" like that, which is why looking at other peoples code is great thing.

          Also, you might look at the <mvcapture> tag if you have a bunch of text/mivascript evaluations to collect as one item. For example, you could basically run an entire page inside <mvcapture> and then show that page with a simple <mveval expr="{g.VariableUsedInMvCapture}">

          (Hey, some one needs to write a 'tip of the day' feature for Mivascript.com...in mivascript of course.)
          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

          Working...
          X