[Beginner] Creating a Document Library Using Asset Listings and Metadata


(Keith Brown) #1

This post aims to give a quick solution to a generic ‘Library’ problem using a pdf document library as an example.


[size=2]

Overview[/size]



To keep things simple I’m setting up the document structure like so:



Library (Standard Page)

–Documents (Folder - Set Link Type 2)

–Non Visible Assets (Folder -Set Link type 2 & Remove Web path)

---- Document Schema (metadata)

---- List Documents (Asset Listing)

–View Document Details (Asset Listing - Set Link Type 2)



The ‘Library’ standard page has the normal WYSIWYG div so editors can tweak the introduction and a nested area that nests the ‘List Documents’ asset. The PDFs are put in the ‘Documents’ folder (with metadata attached) and the ‘View Document Details’ displays the metadata.



[size=2]

Setting Up[/size]



Create the ‘Library’ standard page, the Documents and Non Visible Assets folders (remembering to set the link types and remove webpaths as specified above).



[size=2]

Creating the Metadata Scheme[/size]



Create the ‘Document Schema’ asset under ‘Non Visible Assets’ folder and add the 4 metadata fields the documents I need:



Author (text field)

Reference (text field)

Year (date field - under the options untick all but the year column, ‘show keywords selector’ to no and set the ‘Display Format’ to just ‘Y’)

Abstract (text field - set multi line field option to ‘Yes’)



[attachment=300:metadata_fields.jpg]



Note: The document title will be derived from the uploaded file’s friendly name.



And change ‘Show on Front End’ to No as we don’t want the metadata printed as part of the HTML head.



Apply this metadata schema to the ‘Documents’ folder.



TIP: At this point it is useful to upload 3/4 dummy PDFs to the Documents folder (and fill out the metadata) so that there are assets in place to test the rest of this short tutorial is working as you go through.



[size=2]

Creating the View Document Details asset[/size]



Create the ‘View Document Details’ asset under the ‘Library’ asset (setting Link Type to 2) - we will return to customise this asset fully later but need create it now so we know it’s assetID for the next step.



[size=2]

Creating the List Documents Asset[/size]



Create a new Asset Listing asset called ‘List Documents’ under the ‘Non Visible Assets’ folder then goto the ‘Library’ asset / edit content and add a nested DIV below the WYSIWYG. Choose the ‘List Documents’ asset to nest.



[attachment=304:nested_asset.jpg]



On the Details screen of the ‘List Documents’ asset set



  • 'Asset Types to List' to PDF File
    [*]'Asset Statuses to List' to 'Live'
    [*]'Root Nodes' to the document folder


[attachment=302:list_doc..._details.jpg]

Next on the Display Formats screen edit the Page Contents so that it has the Raw HTML types (I Remember that leaving it in WYSIWIG format confuses HTML tidy as the UL/LI is spilt accross two formats.).

[attachment=305:rawhtml.jpg]

And change the contents to:

    
    %asset_listing%


Repeat this for the Default Format. The raw HTML this time adds a list item around a few keywords derived from the metadata about the document.

    
  • %asset_metadata_Author% (%asset_metadata_Year%) - %asset_attribute_title% [Reference: %asset_metadata_Reference%]


  • Notice that the href points at an assetID (with the 'result_page' parameter set to the document's position in the list) this needs to be the assetID of the 'View Document Details' asset created above.

    You can optionally edit the 'Page Contents (No Results)' format to be a more meaningful message.

    The final customisation we need is on the 'Asset Sorting' Screen.

    Add the two metadata fields 'Author' and 'Year' as options under 'Sorting by Metadata Field Value':

    [attachment=306:sort_metadata.jpg]

    The rearrange the top two items to be 'Author' then 'Year':

    [attachment=307:sortbyoptions.jpg]

    Then set the 'Default Sorting' option to 'Author':

    [attachment=301:defaultsorting.jpg]

    If you view the 'Library' asset it should include the PDF listing sorted in the correct order of Author/Year:

    [attachment=303:list_final.jpg]

    [size=2]
    [b]Setting Up the View Document Details asset[/b][/size]

    The final thing we have to do setup the 'View Document Details' asset. Initally setup the details screen the same as the 'List Documents Asset':

    [list]
    [*]'Asset Types to List' to PDF File
    [*]'Asset Statuses to List' to 'Live'
    [*]'Root Nodes' to the document folder
    [/list]

    Also change the 'Assets Per Page' to be 1.

    You also need to repeat the Assort Sorting steps from above also (to ensure the order is the same for both asset listings and so that the asset_position specified in the URL matches the asset position in the listing).

    [list]
    [*]Add the two metadata fields 'Author' and 'Year' as options under 'Sorting by Metadata Field Value'
    [*]The rearrange the top two items to be 'Author' then 'Year'
    [*]Then set the 'Default Sorting' option to 'Author'
    [/list]

    Save the asset and check that clicking on the link in the 'List Documents Asset' displays the correct asset (a linked filename by default) on the 'View Document Details'page.

    Finally we want to change what gets displayed when you view the 'View Document Details' page. On the Display Formats screen choose the 'Default Format' option, convert to Raw HTML and enter the following:
        
    Author
    %asset_metadata_Author%
    Title
    %asset_attribute_title%
    Year
    %asset_metadata_Year%
    Reference
    %asset_metadata_Reference%
    Abstract
    %asset_metadata_Abstract%
    Download File
    Download PDF of Paper (%asset_file_size_readable%)


    Save and the document details should display the following:

    [attachment=309:viewdoc.jpg]

    I've used a definition list but you can substitute whatever HTML you wish.

    Ans so ends the post. Any suggestions for improvement welcome below. It wont be soon, but if I get some time I'll extend the above example to include an Asset Builder front end... or if someone else wants to do it even better ;-)

    [size=2]
    [b]References[/b][/size]

    [list]
    [*]Remove Web path
    [*]Remove Web path
    [/list] metadata_fields.jpg (23.7 KB) defaultsorting.jpg (6.28 KB) list_documents_details.jpg (51.9 KB) list_final.jpg (19.6 KB) nested_asset.jpg (22.1 KB) rawhtml.jpg (28.4 KB) sort_metadata.jpg (19 KB) sortbyoptions.jpg (24.7 KB) viewdoc.jpg (21.2 KB)

    (Robin Shi) #2

    Hi Kjb,


    I was wondering how the editors update the documents? Is there an admin interface developed for that? Also for each document page uses an asset listing page to display, have you come into any performance issue, how is the loading speed for document details page?



    :D’ /> :D <img src=‘http://forums.matrix.squiz.net/public/style_emoticons/<#EMO_DIR#>/biggrin.gif’ class=‘bbc_emoticon’ alt=’:smiley:



    Robin