Results 1 to 9 of 9

Thread: Linking PDFs to Albums via Theme?

  1. #1

    Question Linking PDFs to Albums via Theme?

    I am finally getting around to scanning my CD booklets. My entire collection is classical, and as you may know, classical CDs often have quite extensive booklets.

    Initially I OCRd the booklets and included the electronic text in the “Personal notes/Review” field for the album. However, some booklets are too long and of course all formatting, images, etc. from the booklets is lost.

    What I would like to do instead is convert each booklet into a single PDF file, and have a link on the album page in OrangeCD to the PDF file. As you know, OCD does not offer the functionality right now to add anything to an album except one cover image and then the media files.

    I was wondering if it would be possible to achieve the desired result via programming of the theme. Not being a programmer, this may all be a pipedream, but if the PDF file is placed in the same directory as the media files, would it be possible to program the theme to look in the “Album path” directory for a file ending in “*.pdf” and then displaying a link to that file on the album page?

    Any thoughts would be greatly appreciated.

    BTW, this spring marks my 10 year anniversary using OCD...

  2. #2
    Join Date
    Oct 2006
    Location
    Posts
    291

    Default

    It has been one of my long-standing desires to have a way to point to PDFs in OCD. Many of the classical labels provide PDFs of the booklets when downloading purchases and HD Tracks and eclassical usually have booklets with their high definition offerings. Chandos lets you download the booklet even if you haven't purchased the tracks from them (they also sell through eMusic). I don't think this should be a huge programming issue for Andrei. OCD already has a way of connecting to web sites for artists and, of course, to the tracks on the same computer for playing and queuing.

    Charles does have me on longevity; my first OCD entry dates from November 2004.
    Last edited by Jazz_North; 05-05-2014 at 01:33 PM.

  3. #3

    Cool Found a Way to Link to PDFs and Other File Types

    I have figured out a way to link to PDF files (and other types of files) in OrangeCD. To make it happen, insert the attached code into your theme file, probably "Default V6.dax" located in "C:\OrangeCD\Templates", in the "::album/ui" section and before the following existing line (or anywhere else in the album section of the template):
    <div class="section" id="lineup">

    It works as follows.

    (1) If media files are linked to an album, OrangeCD stores the path to the album's media folder in the tag called "path." This new code checks if that tag is populated. If it is not, nothing happens. (If you do not have media files linked to an album, you could theoretically use a custom field and manually type in a path and use the tag where that path is stored to link to external files. I wrote this for my own use and so am relying on the media folder.)

    (2) If the path tag is populated, the code shows a new section entitled "External Files" on the album page, with a link entitled "View Files." Clicking that link shows all of the files in the album's media folder. You can then double-click on a file to open it. You could store a PDF file (or any other type of file) in the media folder and open it from here.

    (3) I also wanted to open PDF liner notes from the album page directly without intermediate steps. If I have PDF liner notes, I save them in the album's media folder under the file name "Notes.PDF" and then enter "Liner Notes" in the "Condition" tag (found on the "Album Properties | Library" tab in OrangeCD). The code checks if the condition tag is not empty. If it is not empty (regardless of how it is populated), the code displays a link pointing to the "Notes.PDF" file located in the album's media folder. Clicking the link opens the PDF file. If the PDF file is not in the media folder, the link opens a "page not found" page. (I linked the display of the direct link to the PDF to the Condition tag because I use it to identify albums that have PDF files, but you could use any field, such as a custom field, for this purpose or eliminate the reliance on a populated field entirely to always show the link.)

    Enjoy!
    Attached Files Attached Files

  4. #4
    Join Date
    Oct 2006
    Location
    Posts
    291

    Default

    Charles

    Brilliant! This does just what I was looking for. I'll want to tweak it a bit to fit my display format, but it is an important addition to OCD. Thanks for your work.

    Added after working with the dax:

    I believe one could put any content in the field Condition, even just one letter, because all that the dax does is check whether it has content. I don't believe OCD is capable of acting on what the content actually is. That means that the part of the dax that refers to Condition could be modified to:

    <dax:if(condition)>
    <a href='<daxath/>\Notes.pdf'<dax:condition/></a>
    </dax:if>

    and whatever content the user would put into the field would be displayed instead of "Liner Notes". The file name does have to be Notes.pdf however (which means there's a lot of editing ahead of me).


    I would also note that if someone is already using Condition, there are other fields that could be used, such as Distributor (on the General tab), Location, Status, Borrower (all on the Library tab). Just substitute the name of that field for condition in Charles' dax.
    Last edited by Jazz_North; 05-25-2014 at 04:06 PM.

  5. #5

    Default A few more thoughts

    I agree that the IF condition can only test whether a field is empty or not. I tried to pull the content from the OrangeCD tag into a variable but was not successful. My plan was to then use a script to evaluate the content.

    You could edit the theme to make the file name something other than "Notes.PDF," but the restriction is that it has to be the same file name for all albums so that the link that the template displays on the album page works. Remember that if having the direct link is not important to you, you can put any PDF file (and multiple ones at that) into the album's media folder and open a file from the list after clicking on "View Files."

    The folder where OrangeCD is installed includes the "daxedit.exe" program, which can be used to edit themes. (You can also open the theme with any text editor to edit it, such as Notepad.) After starting daxedit, the right panel shows all of the tags (i.e., database fields) that are available, which is helpful to figure out how to refer to these tags in code.

  6. #6
    Join Date
    Oct 2006
    Location
    Posts
    291

    Default

    You can also create a custom field to use as the IF field if you don't want to use an existing OCD field such as Condition. You can also add Charles' dax to the track page if you want to access the liner notes from there also.

  7. #7
    Join Date
    Oct 2006
    Location
    Posts
    291

    Default

    I have found a little hitch in this. If the path has an apostrophe in it (as in C:\Albums\O'Farrill) then the dax won't work. This is different from the way Play and Queue work as they both allow an apostrophe in the path. I don't know enough to understand why this is the case.

  8. #8

    Default

    The forum replaces ": p" with a smiley icon, so in the below code, replace the icon with : p (no space between : and p).

    Replace
    <a href='<daxath/>'>View Files</a>
    and
    <a href='<daxath/>\Notes.pdf'><dax:condition/></a>

    with
    <a href="<daxath/>">View Files</a>
    and
    <a href="<daxath/>\Notes.pdf"><dax:condition/></a>

    and it will work with paths that include an apostrophe. Not sure why.
    Last edited by Charles_Litton; 05-27-2014 at 04:05 AM.

  9. #9
    Join Date
    Oct 2006
    Location
    Posts
    291

    Default

    Thanks, Charles. That works.

Posting Permissions

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