Announcement

Collapse
No announcement yet.

Fragment text into search links

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

    Fragment text into search links

    Hi I am experimenting. I would like to put a list of text into a fragment, and have each item of text be a link that will search for that term when clicked on. Obviously I can build the links manually, but I'd really like something a little slicker that works automatically.

    So I would like to put into a fragment:

    Dog
    Cat
    Frog

    and when I point at "Dog", I'd like it to be a link like this:

    http://www.url.co.uk/cgi-bin/ss00000...&ACTION=Search

    ..and so on..

    Can this be done, so that I don't have to pre-make all the links?

    Thanks !
    Jez

    #2
    I suspect you can do it your way, but you might find it simpler to have a variable per search term (if not too many), you fill that variable out for each term and then in your layout have the link auto added, with the variable replacing the search text, so you have a dynamic url that shows if its variable is filled out and adds what is filled out into the search string.

    Comment


      #3
      Hi there, thanks for that. There will be a lot of them, and I wanted to avoid having to do any pre-setting up if possible.
      I thought there might some way of using styles or something like that ?

      Comment


        #4
        "Using styles or something like that" isn't something that sounds very fruitful, i'm not even sure what you mean to be honest. If you want a list of links auto created from a list of words, i'd suggest that a text file (search-keywords.txt) could be created, containing each of the keywords separated by a comma e.g. red, green, blue etc. You could then use php within a fragment to loop through each of the phrases separated by a comma within that file and produce the search link as you wish. That would be the best and most obvious way of doing something like this, as you just maintain the simple text file then.

        Comment


          #5
          Yes cool that sounds good...... so, you know what I'm going to say now, don't you ? ;o)

          Comment


            #6
            Originally posted by rookers View Post
            so, you know what I'm going to say now, don't you ? ;o)
            ermm.... "How much will it cost me to get you to do this for me Lee?"


            For what it's worth I'd tackle this using PHP or Javascript.
            I'd create a user defined variable whose value was "dog,cat,frog...." etc - i.e. a comma separated list.
            I'd then use PHP to split/explode this list into an array, loop through the array writing/echoing the required HTML for the link to the document.

            Hope that logic helps.
            Fergus Weir - teclan ltd
            Ecommerce Digital Marketing

            SellerDeck Responsive Web Design

            SellerDeck Hosting
            SellerDeck Digital Marketing

            Comment


              #7
              I'd approach it almost the same, apart from adding the contents into a variable directly. You've said there is quite a few, so managing in a variable input field would be fiddly. I'd prefer to maintain in a text file and link that text file to the variable, so the variable reads from the text file effectively.

              Comment


                #8
                I agree with Lee (I think).

                A bit of javascript can do this automatically. See http://psoug.org/snippet/Javascript-...-words_113.htm for an example.

                Note. This will convert all instances of the text on your page into links.

                Mike
                -----------------------------------------

                First Tackle - Fly Fishing and Game Angling

                -----------------------------------------

                Comment


                  #9
                  I have now achieved this using PHP. I setup a variable that can hold a filename. That variable is selectable on a particular fragment. If that variable is set to some file (a csv file), then the php is invoked. The PHP reads the CSV file and echo's the content to the screen, and builds the links I required.
                  I can have as many lines as I like in the csv file.

                  Perfect. If anyone wants to have the code I can supply FOC in the spirit of the forum.


                  Cheers
                  Jez

                  Comment

                  Working...
                  X