Replace markup with real code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bateman

    Replace markup with real code

    Hi, what I am trying to do is the following, its causing some probs though:

    I have the following in a database:
    [[imagediv 100.jpg This is the description text]]
    This is just some dummy text. It doesn't mean anything and is for
    placeholding use only.

    And want to change it to:
    <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
    height="200" /><br />
    This is the description text</div>
    This is just some dummy text. It doesn't mean anything and is for
    placeholding use only.

    In the future I might want to use different codes ie [[imagediv 100.jpg This
    is the description text]] to reference a different DIV.

    Any ideas?


  • Ray Costanzo [MVP]

    #2
    Re: Replace markup with real code

    Can't say that I follow. What's in the database now? The entire literal
    string from "[[imagediv..." to "placeholdi ng use only."? All in one column?
    What is the purpose of this data? What are you trying to acheive here?

    Ray at work

    "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
    news:OKJaebO0EH A.1292@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hi, what I am trying to do is the following, its causing some probs
    > though:
    >
    > I have the following in a database:
    > [[imagediv 100.jpg This is the description text]]
    > This is just some dummy text. It doesn't mean anything and is for
    > placeholding use only.
    >
    > And want to change it to:
    > <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
    > height="200" /><br />
    > This is the description text</div>
    > This is just some dummy text. It doesn't mean anything and is for
    > placeholding use only.
    >
    > In the future I might want to use different codes ie [[imagediv 100.jpg
    > This is the description text]] to reference a different DIV.
    >
    > Any ideas?
    >[/color]


    Comment

    • bateman

      #3
      Re: Replace markup with real code

      Hi, sorry about that.
      Yeah if I return the field from the database I get:

      [[imagediv 100.jpg This is the description text]]
      This is just some dummy text. It doesn't mean anything and is for
      placeholding use only.

      The reason for this is that I am trying to write a system for a user to
      easily add a article, the bits in [[ ]] will be created by buttons they
      press making it hopefully pretty much foolproof. I don't trust them with
      real code!

      There could be multiple instances of this in the field so what I was hoping
      I could do was something like this (written in non-code code!)

      Take the returned field
      Go through it
      if you find [[ take out the text between [[ and ]]
      split into 3 parts, the first word (imagediv in this case), the picture name
      (100.jpg) and the description text (This is the description text)
      Then replace the [[ ...... ]] with
      <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
      height="200" /><br />This is the description text</div>

      Then I can use the modified string in my code, hopefully showing the picture
      without ever having to explain what a DIV is!



      "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
      message news:uThCCjO0EH A.3692@TK2MSFTN GP14.phx.gbl...[color=blue]
      > Can't say that I follow. What's in the database now? The entire literal
      > string from "[[imagediv..." to "placeholdi ng use only."? All in one
      > column? What is the purpose of this data? What are you trying to acheive
      > here?
      >
      > Ray at work
      >
      > "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
      > news:OKJaebO0EH A.1292@TK2MSFTN GP10.phx.gbl...[color=green]
      >> Hi, what I am trying to do is the following, its causing some probs
      >> though:
      >>
      >> I have the following in a database:
      >> [[imagediv 100.jpg This is the description text]]
      >> This is just some dummy text. It doesn't mean anything and is for
      >> placeholding use only.
      >>
      >> And want to change it to:
      >> <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg"
      >> width="200" height="200" /><br />
      >> This is the description text</div>
      >> This is just some dummy text. It doesn't mean anything and is for
      >> placeholding use only.
      >>
      >> In the future I might want to use different codes ie [[imagediv 100.jpg
      >> This is the description text]] to reference a different DIV.
      >>
      >> Any ideas?
      >>[/color]
      >
      >[/color]


      Comment

      • Aaron [SQL Server MVP]

        #4
        Re: Replace markup with real code

        If the end user doesn't see [[imagediv 100.jpg This is the description
        text]] then why not, when they click the button, just create the whole code?

        Store <img scr=100.jpg alt='This is the description text'> etc...

        Why build two steps to creating HTML? It's HTML, not hyroglyphics...

        --
        Please contact this domain's administrator as their DNS Made Easy services have expired.

        (Reverse address to reply.)




        "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
        news:udQ0ToO0EH A.2200@TK2MSFTN GP09.phx.gbl...[color=blue]
        > Hi, sorry about that.
        > Yeah if I return the field from the database I get:
        >
        > [[imagediv 100.jpg This is the description text]]
        > This is just some dummy text. It doesn't mean anything and is for
        > placeholding use only.
        >
        > The reason for this is that I am trying to write a system for a user to
        > easily add a article, the bits in [[ ]] will be created by buttons they
        > press making it hopefully pretty much foolproof. I don't trust them with
        > real code!
        >
        > There could be multiple instances of this in the field so what I was[/color]
        hoping[color=blue]
        > I could do was something like this (written in non-code code!)
        >
        > Take the returned field
        > Go through it
        > if you find [[ take out the text between [[ and ]]
        > split into 3 parts, the first word (imagediv in this case), the picture[/color]
        name[color=blue]
        > (100.jpg) and the description text (This is the description text)
        > Then replace the [[ ...... ]] with
        > <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
        > height="200" /><br />This is the description text</div>
        >
        > Then I can use the modified string in my code, hopefully showing the[/color]
        picture[color=blue]
        > without ever having to explain what a DIV is!
        >
        >
        >
        > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
        > message news:uThCCjO0EH A.3692@TK2MSFTN GP14.phx.gbl...[color=green]
        > > Can't say that I follow. What's in the database now? The entire[/color][/color]
        literal[color=blue][color=green]
        > > string from "[[imagediv..." to "placeholdi ng use only."? All in one
        > > column? What is the purpose of this data? What are you trying to[/color][/color]
        acheive[color=blue][color=green]
        > > here?
        > >
        > > Ray at work
        > >
        > > "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
        > > news:OKJaebO0EH A.1292@TK2MSFTN GP10.phx.gbl...[color=darkred]
        > >> Hi, what I am trying to do is the following, its causing some probs
        > >> though:
        > >>
        > >> I have the following in a database:
        > >> [[imagediv 100.jpg This is the description text]]
        > >> This is just some dummy text. It doesn't mean anything and is for
        > >> placeholding use only.
        > >>
        > >> And want to change it to:
        > >> <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg"
        > >> width="200" height="200" /><br />
        > >> This is the description text</div>
        > >> This is just some dummy text. It doesn't mean anything and is for
        > >> placeholding use only.
        > >>
        > >> In the future I might want to use different codes ie [[imagediv 100.jpg
        > >> This is the description text]] to reference a different DIV.
        > >>
        > >> Any ideas?
        > >>[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Bob Lehmann

          #5
          Re: Replace markup with real code

          Why don't you keep the image name and description in seperate columns in the
          DB?

          Why does the user have to know anything about <div>? Can't you just output
          that in the code?

          Why are you are making it so hard on yourself with contrived data formats?


          Bob Lehmann

          "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
          news:udQ0ToO0EH A.2200@TK2MSFTN GP09.phx.gbl...[color=blue]
          > Hi, sorry about that.
          > Yeah if I return the field from the database I get:
          >
          > [[imagediv 100.jpg This is the description text]]
          > This is just some dummy text. It doesn't mean anything and is for
          > placeholding use only.
          >
          > The reason for this is that I am trying to write a system for a user to
          > easily add a article, the bits in [[ ]] will be created by buttons they
          > press making it hopefully pretty much foolproof. I don't trust them with
          > real code!
          >
          > There could be multiple instances of this in the field so what I was[/color]
          hoping[color=blue]
          > I could do was something like this (written in non-code code!)
          >
          > Take the returned field
          > Go through it
          > if you find [[ take out the text between [[ and ]]
          > split into 3 parts, the first word (imagediv in this case), the picture[/color]
          name[color=blue]
          > (100.jpg) and the description text (This is the description text)
          > Then replace the [[ ...... ]] with
          > <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
          > height="200" /><br />This is the description text</div>
          >
          > Then I can use the modified string in my code, hopefully showing the[/color]
          picture[color=blue]
          > without ever having to explain what a DIV is!
          >
          >
          >
          > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
          > message news:uThCCjO0EH A.3692@TK2MSFTN GP14.phx.gbl...[color=green]
          > > Can't say that I follow. What's in the database now? The entire[/color][/color]
          literal[color=blue][color=green]
          > > string from "[[imagediv..." to "placeholdi ng use only."? All in one
          > > column? What is the purpose of this data? What are you trying to[/color][/color]
          acheive[color=blue][color=green]
          > > here?
          > >
          > > Ray at work
          > >
          > > "bateman" <bateman_ap@nos pam.hotmail.com > wrote in message
          > > news:OKJaebO0EH A.1292@TK2MSFTN GP10.phx.gbl...[color=darkred]
          > >> Hi, what I am trying to do is the following, its causing some probs
          > >> though:
          > >>
          > >> I have the following in a database:
          > >> [[imagediv 100.jpg This is the description text]]
          > >> This is just some dummy text. It doesn't mean anything and is for
          > >> placeholding use only.
          > >>
          > >> And want to change it to:
          > >> <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg"
          > >> width="200" height="200" /><br />
          > >> This is the description text</div>
          > >> This is just some dummy text. It doesn't mean anything and is for
          > >> placeholding use only.
          > >>
          > >> In the future I might want to use different codes ie [[imagediv 100.jpg
          > >> This is the description text]] to reference a different DIV.
          > >>
          > >> Any ideas?
          > >>[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Evertjan.

            #6
            Re: Replace markup with real code

            bateman wrote on 23 nov 2004 in microsoft.publi c.inetserver.as p.general:
            [color=blue]
            > [[imagediv 100.jpg This is the description text]][/color]
            [color=blue]
            > <div class="imagediv "><img src="/images/100.jpg" alt="100.jpg"
            > width="200" height="200" /><br />This is the description text</div>[/color]

            it is simple string manipulation.

            Using vbscript:

            =============== =============== ==

            s = "[[imagediv 100.jpg This is the description text]]"

            s= replace(s,"[[","")
            s= replace(s,"]]","")

            a = split(s," ")

            r = "<div class='" & a(0) & "'>"

            r = r & "<img src='/images/" & a(1) & "' alt='" & a(1)

            r = r & "' width='200' height='200' /><br />"

            for i=2 to ubound(a)
            r = r & a(i) & " "
            next

            result = left(r,len(r)-1) & "</div>"

            =============== =

            Instring HTML quotes are replaced with single ones.

            I would put the width and height in the css clas description



            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress,
            but let us keep the discussions in the newsgroup)

            Comment

            • Jeff Cochran

              #7
              Re: Replace markup with real code

              On Mon, 22 Nov 2004 23:01:04 -0000, "bateman"
              <bateman_ap@nos pam.hotmail.com > wrote:
              [color=blue]
              >Hi, what I am trying to do is the following, its causing some probs though:
              >
              >I have the following in a database:
              >[[imagediv 100.jpg This is the description text]]
              >This is just some dummy text. It doesn't mean anything and is for
              >placeholding use only.
              >
              >And want to change it to:
              ><div class="imagediv "><img src="/images/100.jpg" alt="100.jpg" width="200"
              >height="200" /><br />
              >This is the description text</div>
              >This is just some dummy text. It doesn't mean anything and is for
              >placeholding use only.
              >
              >In the future I might want to use different codes ie [[imagediv 100.jpg This
              >is the description text]] to reference a different DIV.
              >
              >Any ideas?[/color]

              First idea is to stop trying to do this. Keep data in the database,
              markup in your page language. Second is to learn to use a database.
              The image file name is an attribute. The image description is an
              attribute. Attributes define your columns. So you should have:

              ImageNumber - An autoassigned number to use as a unique key
              ImageFileName - The actual file name (possibly with path, or a
              separate column for path)
              ImageDescriptio n - The descriptive text about the image.

              Retrieve the image file name from your database, display that file
              along with the description.

              And until the user places the data in the database, you don't need a
              place holder. Don't create the record.

              Jeff

              Comment

              Working...