Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 26
  1. #1
    Senior Member Aleister's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    250
    Member #
    2329
    One of my web sites is a fan site for a band I like. I want to put all the lyrics up on the site, preferably each in their own htm file.

    Now I could go through and manually create a single file for each one, making a copy of my 'template' and just pasting in the text, saving, moving to the next, etc... but on this site, the navigation is on every page, and I use dreamweaver's built in template function to modify things like navigation etc.. so the changes are made on every file.

    I don't really want to add several hundred 'regular' htm files to the site, as it will take much longer to upload every single one when I change something in the template (which I do quite often).

    I am looking for a method to keep the individual lyrics in simple text files, and use php or something (which I have no experience with) to only have a single lyrics.htm, which can import the text file I want.

    Is php the best option for this ? To do it properly I suppose I could not just use simple text files for each lyric, but rather a simple html file (so I could have the styles I want.. headings.. etc..)

    Any thoughts ? It will still be a lot of work this way (probably anyway), but at least it will not increase the time it takes DW to update all the files, or me to upload them. Sorry for the long post.. any comments are appreciated!
    The Temple of Dagon | Dagon Design
    "That is not dead which can eternal lie, And with strange aeons even death may die." - HPL

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    This would be excuciatingly easy

    Just come up with a simple format to the text file, like:
    Song Title
    Album
    Additional Notes

    Lyrics go here...
    .............
    .................
    What you would do is tell php to take one line at a time for the first 3 lines, and then for the remaining text you use nl2br to convert the new lines in the text to <br> so they appear as new lines in the html.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Member macgruder's Avatar
    Join Date
    Apr 2004
    Location
    Japan
    Posts
    97
    Member #
    5524
    If you are going to go as far as php, you may as well use a database too. Mysql is the obvious choice.

  5. #4
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    If you are going to go as far as php, you may as well use a database too. Mysql is the obvious choice.
    I think if you've already got the files there there's no need to go to the effort of creating a DB for it.

    I've done several projects in PHP which are essentially glorified directory listings with text file encapsulating.

    See http://www.lonsdalecentre.com or the mars site in my sig.


    Anyway, the first step is to design a template lyrics page with a message saying something like 'LYRICS GO HERE'. When you're happy, copy everything before 'LYRICS GO HERE' into a file called head.php, and everything after it into a file foot.php.

    The write a file called showlyrics.php,
    PHP Code:
    <?php include "head.php";
    $lyrics=implode("<br/>"file($file));
    echo 
    $lyrics;
    include 
    "foot.php";
    ?>
    Next you'll have to think about where these files are in relation to the lyrics text files. For example, lets say you put head.php, foot.php and showlyrics.php in the root of www.mysite.com, and your lyrics are in www.mysite.com/lyrics.
    You can then view one of the lyrics by navigating to
    http://www.mysite.com/showlyrics.php...rics/song1.txt

    It's like magic. This example is pretty unsecure, so don't use it in production, but it's easy to make it secure.
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  6. #5
    Senior Member Aleister's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    250
    Member #
    2329
    Well I really don't want to have to put the header and footer for my template into seperate files. Since I am using DreamWeaver, with a template.. So I can modify my template and have it adjust all the files that use it automatically. If I were to stick the header and footer into the new files I would have to update it manually constantly.

    Couldnt I just take my lyrics.htm (that is the current way I have it), rename it .php, and stick the place in it to insert the lyrics file?

    I just have never done any php whatsoever so I am trying to keep it both simple, yet relatively secure. I can't find any tutorial sites for exactly what I am trying to do.
    The Temple of Dagon | Dagon Design
    "That is not dead which can eternal lie, And with strange aeons even death may die." - HPL

  7. #6
    Senior Member james's Avatar
    Join Date
    May 2003
    Location
    Melbourne, AUSTRALIA
    Posts
    364
    Member #
    1352
    OK, somebody should be able to help you, I'm not very familiar with Dreamweaver.
    If nobody can, I'll just have to learn myself some Dreamweaver!

    Could you post a link to your site, and perhaps attach lyrics.htm to a post?
    James H
    Home Page · Mars Page · www.fihsf1.net (formerly www·fihs·net)

  8. #7
    Senior Member Aleister's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    250
    Member #
    2329
    Well I don't have the lyrics file up quite yet.. But as I have been researching more.. I am going to do something like this for the links :

    <a href="http://whatever/lyrics.php?file=test1">test1</a>

    Then I am going to have a file that is basically just a copy of my template, with no content in it.. but it has the php command to load the file passed on to it. Sound ok?

    I have the basic code down for this now, but I just need to learn how to secure it better. Someone had the idea of having the code add on the php extension itself (to make it only open php files) .. could the same be done for the directory the files are in? like, could I do something like this? :

    open( "www.mysite.com/dir/" + $filename + ".php" )

    Thats just a generic example.. not actually php code.. This is the final part I need help with. Basically the code I would need in my file to do the following:

    take the filename (which is the parameter passed on to the php file), and add the "http://whatever/lyrics/" in front, and ".php" at the end.

    Sounds simple enough, but that little bit of code is whats throwing me off.. any ideas?
    The Temple of Dagon | Dagon Design
    "That is not dead which can eternal lie, And with strange aeons even death may die." - HPL

  9. #8
    Junior Member
    Join Date
    Apr 2004
    Posts
    1
    Member #
    5576
    PHP:

    if(isset($_GET['num']))
    {
    $song = $_GET['song'];
    } else {
    $song = 'index';
    }

    This block sets the variable song to the name of the song, if its not in the querystring, it sets it to index.

    Then, just put this where you put your content:

    <?php include("songs/".$song.".php"); ?>

    Then, for each song, make a file songname.php, put it in the songs folder, and there ya go.



    Not sure how Dreamweaver would handle this, I don't beleive it wold show anything in the song lyrics section...

  10. #9
    Senior Member Aleister's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    250
    Member #
    2329
    I ended up doing this..

    PHP Code:
    <?php     
    $page_location 
    $lyric ".php";
    if(
    $lyric && file_exists($page_location)) {
         include(
    $page_location);
    }
    else {
         include(
    "empty.php"); /* gives a link back */
         
    echo "Error!";
    }
    ?>
    comments?
    The Temple of Dagon | Dagon Design
    "That is not dead which can eternal lie, And with strange aeons even death may die." - HPL

  11. #10
    Member macgruder's Avatar
    Join Date
    Apr 2004
    Location
    Japan
    Posts
    97
    Member #
    5524
    Originally posted by james
    I think if you've already got the files there there's no need to go to the effort of creating a DB for it.
    Well, the advantage of the DB would be

    - searching would be easy to implement
    - insert a new lyric(copy, paste) and all the the links could fairly easily be updated on any index page automatically
    - maintaining the site would be substantially easier
    - lyrics could be displayed how you wanted (Title only, Title plus first line, Title plus first 100 words etc, most popular linked, or whatever, alphabetical by name, starting with the letter 'a', 'b' etc)

    For more than a few files, the limitations of filebased system quickly become apparent. Of course, the advantage is that you don't have to learn to use a database, but at this level it would be a fairly straightforward job, and if you're interested in php in general this would be the perfect opportunity to do so.


Page 1 of 3 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:54 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com