Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Are dynamic links possible?

  1. #1
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Are dynamic links possible?

    Hi,

    Is there a script that can allow you (maybe using XML or something) to insert a list of words in a file and then, if those words appear on your page it will automatically make them linkable to a specific place you want to go?

    I have been searching, but I dont know what exactly the name is being used for this situation so I havent been very fortunate to find anything.

    Any help/info would be greatly appreciated!! Thanks!!

    Kreven

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm sure it's possible... somehow.

    There are some very vague aspects of your question:
    1. "insert".... user? you? before processing? textbox on the page? on the server? client's computer? etc.
    2. How do they relate... if the word appears on the page, then... it goes to the same page? A page like "word.htm"? a page you set by word (as pairs of words/pages)?
    3. Would these pages need to be generated? dynamic? pre-exist?

    Also, for the list of words, could this be specifically set, or would it need to be easy to change (by you? the user?)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2007
    Location
    Phoenix, AZ
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think I got some malicious code in my browser once that did that. Every page I pulled up would have words highlighted, and if you clicked on them it took you to some advertiser's site. Very weird. And annoying. I had to reset all of my browser settings/prefs to get rid of it.

  4. #4
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    I'm sure it's possible... somehow.

    There are some very vague aspects of your question:
    1. "insert".... user? you? before processing? textbox on the page? on the server? client's computer? etc.
    I would like to, not the user. For example, I have a page with various countries information and if the word, "Japan" is in the text of the webpage I've created, I want it(the word "Japan") to appear as a link to the "japan/index.html" page and so forth for other countries. And I it would be controlled from the server on my side. (therefore would work for anyone that visited the site)

    Quote Originally Posted by djr33 View Post
    2. How do they relate... if the word appears on the page, then... it goes to the same page? A page like "word.htm"? a page you set by word (as pairs of words/pages)?
    I think its answered above.

    Quote Originally Posted by djr33 View Post
    3. Would these pages need to be generated? dynamic? pre-exist?

    Also, for the list of words, could this be specifically set, or would it need to be easy to change (by you? the user?)
    I'm not sure what you would call it, but I dont want to have to manually do it all the time because that top page will be changing all the time with those words (its a whats new area).

    I hope my description can be understood. I have a feeling I've seen it around as well (but my intention isnt to use it as spam or whatever).

    Thanks again!

    Kreven

    Its similar to this option: "Automatically parse links in text" is similar I think but instead of when it sees http or www or whatever it will be a country and link to that countries page (which hopefully can be entered in somewhere).

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    When I said generated dynamically, I wasn't asking about the links. I'm aware that the text must be parsed for those. What I was asking about was the list.

    Anyway.... here's how I think it should work...

    Here is some PHP code for your page;
    Just fill in the blanks as you wish:
    PHP Code:
    <?php
    $words 
    = array(
    array(
    'apple','http://apple.com'),
    array(
    'orange','http://orange.com'),
    array(
    'banana','http://banana.com')
    ); 
    //setup your words/urls
    //copy pattern above
    //last one needs no comma

    $f file_get_contents('**thispage***.php'); //get contents of this page
    list($f,$null) = explode('/*END*/ ?>',$f); //take of this php from top
    list($f,$null) = explode("/n",$f); //get rid of extra line

    foreach($words as $word) {
    $f str_replace($f,$word[0],'<a href="'.$word[1].'">'.$word[0].'</a>');
    }
    //replace all words with links

    echo $f//output page

    die(); //end script execution
    //and don't output rest of page
    //it's already output by script

    /*END*/ 
    ?>
    <html>
    the rest of your page goes here
    whatever you want
    Oh, and you can't use any more PHP on the page
    or it would get complex
    there are ways around it, though
    but let me know if you need that,
    and we cant work it out
    Also, this would cause issues if
    the keywords are in the code
    like if you used 'div' as a keyword
    it would parse <div> to be a link
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Brilliant!! thanks! I will try this right away, this looks like it can work!!

    Not a php pro but I know coding in general. (I can read, understand and edit but never been good at creating from scratch)

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Good. I hope it does work.
    I'm a bit distracted right now.
    I think the basic structure is there, might need some work. Lemme know.

    Also, the huge issue here is dealing with the fact that it doesn't parse html... so it doesn't know what is a word and what is not, and doesn't parse other PHP. It's complex. It would be possible to write this, but it would be a lot more work.
    I'd suggest using a javascript method (which I can't write) if you need other server side code on the page (though having it skip <?php and ?> is easy... not getting it to perform those, though).
    As for parsing the html... I'd suggest looking for a base script on which it could be built.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well as of now it is pure HTML and has no plans of adding any more scripts to that page. (Only script it has is basic rollover button JS)

    Anyway I will try it and see how it goes!!

    Kreven

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure.

    One way to cheat and not fully require that it be parsed as html to check if the word is a word, not code, would be to check it's placement:
    " word "
    "/nword."
    " word!"
    etc/mix thereof
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Error message popped: Fatal error: Call to undefined function: file_get_contents() in /index2.php on line 10

    This is line 10:
    Code:
    $f = file_get_contents('index2.php'); //get contents of this page
    Don't think it liked this function. Believe the php version im using is 5.0. If it was version 4.0 would there be a problem?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •