Add the Facebook Like button (iframe) on Cascade Pages

Allie's Avatar

Allie

19 Oct, 2010 01:58 AM

Hi there,
Has anyone tried to add the Facebook Like button (the iframe version) on Cascade pages that captures the dynamic page URLs? I tried to add the iframe code to XSLT (via xalan), to the template via JQuery (the button needs to be inserted at a specific place on a page), and to a XHTML block (embedding the Javascript code), but the <iframe> tag either is not accepted by Cascade or Cascade processes the code and renders something less than useful. Is this possible to do in Cascade (version 6.7.2)?
Thanks in advance!
-Allie

  1. 1 Posted by Allie on 21 Oct, 2010 10:11 PM

    Allie's Avatar

    I have eventually made this work by using a current page index as a block, and writing the iframe code in the block's format to capture the current page URL.

  2. Allie closed this discussion on 21 Oct, 2010 10:11 PM.

  3. Allie re-opened this discussion on 28 Oct, 2010 09:56 PM

  4. 2 Posted by Allie on 28 Oct, 2010 09:56 PM

    Allie's Avatar

    Hey, I thought I figured this out, but the code does not quite do the job yet.

    I want to generate code like this:
    <iframe src="http://mysite.com/path/to/the/file.html"></iframe>

    I use the following xslt:
    <xsl:element name="iframe"><xsl:attribute name="src"><xsl:value-of select="path"/></xsl:attribute></xsl:element>

    What I get is:
    <iframe src="/cascade/basefolder/path/to/the/file"></iframe>

    I can get the desired URL using this:
    <a href="{path}"> good URL </a> --> <a href="http://mysite.com/path/to/the/file.html"> good URL </a>

    What am I doing wrong here? Thanks!

  5. 3 Posted by Penny on 29 Oct, 2010 02:42 PM

    Penny's Avatar

    The following code should produce what you are wanting. Something to note is that path will be rewritten correctly on publish with the correct .html extension. The substring bit ensures when the link is rewritten relatively the whole path is output when live, rather than just index.html.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="system-index-block">
            <xsl:apply-templates select="//calling-page/system-page"/>
        </xsl:template>
        <xsl:template match="system-page">
            <xsl:variable name="nameLength" select="string-length(name)"/>
            <xsl:variable name="pathLength" select="string-length(path)-$nameLength"/>
            <iframe src="[system-view:external]http://mysite.com[/system-view:external]{substring(path, 1, $pathLength)}[system-asset]{path}[/system-asset]"></iframe>
        </xsl:template>
    </xsl:stylesheet>
  6. 4 Posted by Allie on 29 Oct, 2010 06:44 PM

    Allie's Avatar

    Thanks much for this, Penny.
    Capturing the file extension remains to be a challenge. Is there a way to address that using Cascade methods? If not, a non-Cascade way? Any thoughts would be appreciated!

  7. 5 Posted by Penny on 29 Oct, 2010 07:34 PM

    Penny's Avatar

    Using the [system-asset] tags, the .html should be added at publish time when that tag is recognized. Have you tried publishing this page? If so, what version of Cascade are you working within?

  8. 6 Posted by Allie on 01 Nov, 2010 12:49 AM

    Allie's Avatar

    Thanks, Penny. It works for .html and .shtml - I assume it works for other file extension as well, such as .php. One more question:[system-asset]{path}[/system-asset] captures file name + file extension at publish time - I would expect [system-asset]{name}[/system-asset] generate such result. Thanks again.

  9. 7 Posted by Penny on 01 Nov, 2010 02:05 PM

    Penny's Avatar

    You will want to use path because the system-asset tags will need a valid path to rewrite and add the extension. So [system-asset]name[/system-asset] will not produce a valid path if your page is stored in a sub-folder.

    This will work for any extension that you choose to use. It just concatenates the path with whatever extension you have set on your Configurations.

    Please let me know if you need further clarification.

  10. 8 Posted by Allie on 01 Nov, 2010 09:41 PM

    Allie's Avatar

    Thanks again, Penny!

  11. Allie closed this discussion on 01 Nov, 2010 09:41 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac