Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sam Aspin 11 posts 31 karma points
    Oct 07, 2009 @ 17:33
    Sam Aspin
    0

    Build a dynamic url to link to google docs

    Hi guys,

    I'm trying to build a couple of direct links to a google doc inside my site.... the links im trying to build look like this...

    http://docs.google.com/MiscCommands?command=saveasdoc&exportformat=doc&docID=[MYVARIABLEDOCUMENTID]

    i have added a textstring field to my page to hold the document id and have successfully displayed this on the page using an xslt and a macro inserted in the RTE of the page.  This works fine just displaying as text on a page however, I need to insert this url inside an <a href tag within the RTE

    Obvisouly, when you insert a macro it wraps it in a div and span etc.

    Is this something i can achieve within the RTE of my page content or do I need to take a different approach?

    Thanks in advance

    Sam : )

  • Rich Green 2246 posts 4008 karma points
    Oct 07, 2009 @ 18:12
    Rich Green
    0

    Inserting a macro alone does not insert *any* extra code/text (divs or spans included)!

    I suggest you post your XSLT here to give everyone a better idea of what the problem is.

    Rich

  • Sam Aspin 11 posts 31 karma points
    Oct 07, 2009 @ 18:33
    Sam Aspin
    0

    Thanks Rich, i had a look and found the spans in the xslt so have whipped them out... however i still get the div when i insert the macro in the RTE.  when i click to edit the html this is what i see...

    <table border="0">
    <tbody>
    <tr>
    <td><a href="" <img src="/media/1545/downloaddoc2copy.jpg" alt="DownloadCVdoc" width="251" height="259" rel="251,259" /></a></td>
    <td><a href="http://docs.google.com/MiscCommands?command=saveasdoc&amp;exportformat=pdf&amp;docID=0AScEyQ9GC2UFZHY3NGYydF8xM2hydmRzZmN2&amp;hl"> <img src="/media/1595/downloadpdf.jpg" alt="DownloadCVpdf" width="251" height="259" rel="251,259" /></a></td>
    </tr>
    <tr>
    <td>id :
    <div umb_macroalias="GoogleCVID" ismacro="true" onresizestart="return false;" umbversionid="4814f220-ab7b-471f-a14d-952c5fbf1fcc" umbpageid="1119" title="This is rendered content from macro" class="umbMacroHolder"><!-- startUmbMacro -->cvtest<!-- endUmbMacro --></div>
    </td>
    </tr>
    </tbody>
    </table>

    If you look where it says <td>id: - this is the point where i inserted the macro using the 'insert macro' button and the div below it is the result..... perhaps this is a side effect of using the insert macro button, is it possible to write the code to call the macro instead?

    I havent included the XSLT but can do if you'd still like to see it.

  • Rich Green 2246 posts 4008 karma points
    Oct 07, 2009 @ 18:55
    Rich Green
    0

    Sorry, missed the bit where you mentioned you're adding the macro via the RTE.

    You could try going to your macro and deselecting "Render content in editor", then add the macro again. 

    However do you really need the macro to be adding via the RTE, or can you add it directly to the template?

    Also if you post your xslt then i'm sure someone can help.

    Rich

  • Sam Aspin 11 posts 31 karma points
    Oct 07, 2009 @ 19:58
    Sam Aspin
    0

    Okay, sounds like I'm approaching this from the wrong angle!

    My basic aim is to have 2 download images, each link to a similar url with the same CVID as one of the parameters, the links would look like this...

    url 1 : http://docs.google.com/MiscCommands?command=saveasdoc&amp;exportformat=pdfamp;docID=[CVID]
    url 2 : http://docs.google.com/MiscCommands?command=saveasdoc&amp;exportformat=pdfamp;docID=[CVID]

    As I said, i have the CVID as a field on my page, just need to get the CVID into the href tag!

    Any ideas how it should be done?!

    here's the xslt that returns the google doc id

    ********************************************************
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">


        <xsl:output method="xml" omit-xml-declaration="yes"/>

        <xsl:param name="currentPage" select="$currentPage/.."/>

        <xsl:template match="/">

            <!--
            ============================================================
            If the current node property PhotoText is NOT empty then
            we display a span with the PhotoText property in.
            ============================================================
            -->
            <xsl:if test="$currentPage/data [@alias ='CVID'] != ''">
                    <xsl:value-of select="$currentPage/data [@alias ='CVID']"/>
            </xsl:if>


        </xsl:template>

    </xsl:stylesheet>

  • Tom Maton 387 posts 660 karma points
    Oct 07, 2009 @ 21:10
    Tom Maton
    0
    <xsl:if test="$currentPage/data [@alias ='CVID'] != ''">
                    <a href="docs.google.com/MiscCommands{$currentPage/data [@alias ='CVID']}">My Google Link</a>
    </xsl:if>

    Off the top of my head, I believe that should work

    Tom

  • Sam Aspin 11 posts 31 karma points
    Oct 08, 2009 @ 00:40
    Sam Aspin
    0

    I took a new approach and probably the more 'umbraco' way and was getting pretty close, but your code was spot on Tom.  Its working right now which is the main thing and i might try the better engineered approach later!

    Thanks you both for your help guys, thats great

    : )

Please Sign in or register to post replies

Write your reply to:

Draft